[recipes] pass the directories of recipes as argument of create_recipes
so it's usable as is from other cubes (eg. jpl)
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
from cubes.apycot import recipes
class ApycotNoTestTC(utils.ApycotBaseTC):
_repo_path = (u'project',)
def test_quick_recipe_no_data(self):
with self.admin_access.client_cnx() as cnx:
tc = cnx.find('TestConfig', name='tc_project').one()
pe = cnx.find('ProjectEnvironment', name='pe_project').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)
expected = {'pyunit': 'nodata'}
for checker in te.checkers:
self.assertEqual(expected[checker.name], checker.status, checker.log_file[0].read())
def test_full_recipe(self):
with self.admin_access.client_cnx() as cnx:
pyp = cnx.find('TestConfig', name='PYTHONPACKAGE').one()
tc = cnx.find('TestConfig', name='tc_project').one()
pe = cnx.find('ProjectEnvironment', name='pe_project').one()
# ensure recipes content
recipes.create_recipes(cnx, recipes.__file__, update=True)
recipe = cnx.find('Recipe', name="apycot.python.full").one()
self.assertTrue(cnx.find('Recipe', name="apycot.checkout.mercurial"))
self.assertTrue(cnx.find('Recipe', name="apycot.setup.distutils"))
tc2 = self.add_test_config(cnx, u'full config', env=pe, group=pyp,
use_recipe=recipe,
check_config=u'python_lint_treshold=8\npouet=5\nkeep_test_dir=1')
te = tc2.start(pe).eid
cnx.commit()
self.run_plan(te)
with self.admin_access.client_cnx() as cnx:
te = cnx.entity_from_eid(te)
expected = {'pyunit': 'nodata',
'pylint': 'error',}
for checker in te.checkers:
self.assertEqual(expected[checker.name], checker.status,
'%s != %s\nlog=%s\nexecution_log=%s\nTE log=%s' % (
expected[checker.name], checker.status,
checker.log_file[0].read(), te.execution_log[0].read(),
te.log_file[0].read()))
# as we added keep_test_dir=1 in the options, we expect to
# have kept the execution test directory, and that path is
# reported as a CheckResultInfo
rset = cnx.execute('Any V WHERE CR for_check %(eid)s, CR label %(lbl)s, CR value V',
{'eid': te.eid, 'lbl': 'tmpdir'})
self.assertEqual(1, len(rset))
tmpdir = str(rset[0][0])
self.assertTrue(osp.exists(tmpdir))
self.assertTrue(osp.exists(osp.join(tmpdir, 'src', str(pe.local_repository[0].eid))))
self.assertFalse(te.execution_archive)
if __name__ == '__main__':
unittest_main()