[test] update test_functional draft
authorDavid Douard <david.douard@logilab.fr>
Fri, 14 Nov 2014 12:44:03 +0100
changeset 1770 43ee4499b0a2
parent 1769 8e817371cba1
child 1771 3673586bc3d6
[test] update test_functional
test/test_functional.py
--- a/test/test_functional.py	Sun Oct 26 23:30:28 2014 +0100
+++ b/test/test_functional.py	Fri Nov 14 12:44:03 2014 +0100
@@ -7,14 +7,14 @@
 
 import cubicweb.devtools
 import cubes.apycot.testutils as utils
-
+from cubes.apycot.recipes import create_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_project1').one()
-            pe = cnx.fond('ProjectEnviironment', name='pe_project1').one()
+            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)
@@ -26,32 +26,42 @@
 
     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.python.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
+            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
+            create_recipes(cnx, 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)
-            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),
-                                 )
+            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()