import os
import os.path as osp
from shutil import rmtree
from logilab.common.shellutils import unzip
from logilab.common.testlib import unittest_main
import cubicweb.devtools
import cubes.apycot.testutils as utils
DATA = osp.join(osp.dirname(__file__), 'data')
os.environ['HGRCPATH'] = os.devnull
class ApycotTC(utils.ApycotBaseTC):
_repo_path = (u'project',)
def test_quick_recipe(self):
with self.admin_access.client_cnx() as cnx:
tc = cnx.find('TestConfig', name='tc_project1').one()
pe = cnx.fond('ProjectEnviironment', name='pe_project1').one()
te = tc.start(pe).eid
cnx.commit()
self.run_plan(te)
with self.admin_access.client_cnx() as cnx:
te = cnx.entity_from_eid(te)
self.assertEqual(dict((checker.name, checker.status) for checker in te.checkers),
{'pyunit': 'nodata'})
def test_full_recipe(self):
with self.admin_access.client_cnx() as cnx:
lgce = cnx.entity_from_eid(self.lgce)
recipe = cnx.execute('Recipe X WHERE X name "apycot.recipe.full"').get_entity(0, 0)
# reset recipe content
recipe.cw_set(script=full_script)
tc = self.add_test_config(cnx, u'full config', env=self.lgce, group=self.pyp,
use_recipe=recipe)
te = tc.start(lgce).eid
cnx.commit()
self.run_plan(te)
with self.admin_access.client_cnx() as cnx:
te = cnx.entity_from_eid(te)
exp = {u'pycoverage': u'error', u'pyunit': u'nodata'}
try:
# do only check pylint tests where executed if pylint
# is available
from pylint import checkers as pycheckers
from pylint.lint import PyLinter
from pylint.__pkginfo__ import version as pylint_version
from pylint.interfaces import IReporter
from pylint.reporters import BaseReporter
exp['pylint'] = u'error'
except:
pass
self.assertDictEqual(exp,
dict((checker.name, checker.status) for checker in te.checkers),
)
if __name__ == '__main__':
unittest_main()