[test] improve unittest_entities draft
authorDavid Douard <david.douard@logilab.fr>
Fri, 14 Nov 2014 12:39:29 +0100
changeset 1756 09b448c89cf7
parent 1755 0c3fd79885cb
child 1757 224cd20b7284
[test] improve unittest_entities
test/unittest_entities.py
--- a/test/unittest_entities.py	Thu Nov 13 14:59:40 2014 +0100
+++ b/test/unittest_entities.py	Fri Nov 14 12:39:29 2014 +0100
@@ -23,26 +23,17 @@
 class ApycotConfigTC(ApycotBaseTC):
     _repo_path = (u'project1',)
 
-    def setup_database(self):
-        ApycotBaseTC.setup_database(self)
-        with self.admin_access.repo_cnx() as cnx:
-            pyp = cnx.find('TestConfig', name='PYTHONPACKAGE').one()
-            pe = cnx.find('ProjectEnvironment').one()
-            self.add_test_config(cnx, u'tcd', check_config=None,
-                                 env=pe, group=pyp)
-            cnx.commit()
-
     def test_refinement_base(self):
         with self.admin_access.client_cnx() as cnx:
             pe = cnx.find('ProjectEnvironment').one()
             pyp = cnx.find('TestConfig', name='PYTHONPACKAGE').one()
-            tcd = cnx.find('TestConfig', name='tcd').one()
+            tcd = cnx.find('TestConfig', name='tc_quick').one()
             self.assertEqual(pe.apycot_process_environment(),
                              {'DISPLAY': ':2.0', 'SETUPTOOLS': '1'})
             self.assertEqual(pyp.apycot_process_environment(),
                              {'DISPLAY': ':1.0', 'NO_SETUPTOOLS': '1'})
 
-            self.assertEqual(tcd.apycot_configuration(pe),
+            self.assertEqual(pyp.apycot_configuration(pe),
                               {'python_lint_treshold': '7',
                                'python_lint_ignore': 'thirdparty',
                                'python_test_coverage_treshold': '70',
@@ -51,7 +42,7 @@
     def test_refinement_override(self):
         with self.admin_access.client_cnx() as cnx:
             pe = cnx.find('ProjectEnvironment').one()
-            tc = cnx.find('TestConfig', name='tc_project1').one()
+            tc = cnx.find('TestConfig', name='tc_quick').one()
             self.assertEqual(tc.apycot_configuration(pe),
                               {'python_lint_treshold': '8',
                                'python_lint_ignore': 'thirdparty',
@@ -88,8 +79,9 @@
         tcncstrs = self.schema['TestConfig'].rdef('name').constraints
         self.assertEqual([cstr.type() for cstr in tcncstrs], ['RQLUniqueConstraint', 'SizeConstraint'])
         with self.admin_access.client_cnx() as cnx:
-            pe = cnx.find('ProjectEnvironment').one()
-            cnx.create_entity('TestConfig', name=u'lgd', use_environment=pe)
+            pe, tcname  = cnx.execute('Any PE, TCN WHERE PE is ProjectEnvironment, '
+                                      'TC use_environment PE, TC name TCN').rows[0]
+            cnx.create_entity('TestConfig', name=tcname, use_environment=pe)
             self.assertRaises(ValidationError, cnx.commit)
 
     def test_status_change(self):