[test] improve hooks tests draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:59:40 +0100
changeset 1755 0c3fd79885cb
parent 1754 e541bef11cff
child 1756 09b448c89cf7
[test] improve hooks tests
test/unittest_hooks.py
--- a/test/unittest_hooks.py	Thu Nov 13 14:57:28 2014 +0100
+++ b/test/unittest_hooks.py	Thu Nov 13 14:59:40 2014 +0100
@@ -20,6 +20,7 @@
 
 
 class NotificationTC(ApycotBaseTC):
+    _repo_path = (u'project1',)
 
     def setup_database(self):
         super(NotificationTC, self).setup_database()
@@ -30,10 +31,11 @@
             cnx.commit()
 
     def start_lgc_tests(self):
+        self.refresh()
         with self.admin_access.client_cnx() as cnx:
-            lgc = cnx.entity_from_eid(self.lgc)
-            lgce = cnx.entity_from_eid(self.lgce)
-            plan = lgc.start(lgce)
+            pe = cnx.find('ProjectEnvironment').one()
+            tc = cnx.find('TestConfig', name='tc_quick').one()
+            plan = tc.start(pe)
             cnx.commit()
             return plan.eid
 
@@ -72,7 +74,7 @@
             self.assertEqual(len(MAILBOX), 1)
             self.assertEqual(MAILBOX[0].recipients, ['admin@cubicweb.org'])
             self.assertEqual(MAILBOX[0].message.get('Subject'),
-                             '[data] lgce/lgc#default now has 2 failure')
+                             '[data] pe_project1/tc_quick#default now has 2 failure')
             self.assertMultiLineEqual(clean_str(MAILBOX[0].message.get_payload(decode=True)),
                                       '''The following changes occured between executions on branch default:
 
@@ -107,7 +109,7 @@
             self.assertEqual(len(MAILBOX), 1)
             self.assertEqual(MAILBOX[0].recipients, ['admin@cubicweb.org'])
             self.assertEqual(MAILBOX[0].message.get('Subject'),
-                             '[data] lgce/lgc#default: success -> failure (unittest)')
+                             '[data] pe_project1/tc_quick#default: success -> failure (unittest)')
             self.assertMultiLineEqual(clean_str(MAILBOX[0].message.get_payload(decode=True)),
                                       '''The following changes occured between executions on branch default:
 
@@ -121,8 +123,7 @@
     def test_nosy_list_propagation(self):
         planeid = self.start_lgc_tests()
         with self.admin_access.client_cnx() as cnx:
-            cnx.execute('SET X interested_in PE WHERE X login "anon", PE eid %(pe)s',
-                         {'pe': self.lgce})
+            cnx.execute('SET X interested_in PE WHERE X login "anon"')
             cnx.commit()
             # do not propagate to existing test execution
             plan = cnx.entity_from_eid(planeid)
@@ -131,23 +132,6 @@
 
 class StartTestTC(ApycotBaseTC):
     _repo_path = (u'project1',)
-    
-    def setUp(self):
-        super(StartTestTC, self).setUp()
-        r = self.repo
-        with self.admin_access.repo_cnx() as cnx:
-            vcsrepo = cnx.find('Repository').one()
-            path = vcsrepo.localcachepath
-        return
-    
-        os.system('hg init %s' % r.path)
-        os.system('echo data > %s/tutu.png' % r.path)
-        os.system('hg -R %s add %s/tutu.png' % (r.path, r.path))
-        os.system('hg -R %s commit -m rien -u narval' % r.path)
-        # reset vcsrepo
-        with r.internal_cnx() as cnx:
-            bridge.import_content(cnx, commitevery=1, raise_on_error=True)
-
 
     def get_tc(self, cnx, period=None):
         rql = ('Any PEN, TCN, TCS  WHERE TC in_state S, '
@@ -364,16 +348,15 @@
         the correct code and crashes before sending any status, the returned
         status should NOT be waiting execution"""
         with self.admin_access.client_cnx() as cnx:
-            lgc = cnx.entity_from_eid(self.lgc)
-            lgce = cnx.entity_from_eid(self.lgce)
-            te = lgc.start(lgce, branch=u'default')
+            pe = cnx.find('ProjectEnvironment').one()
+            tc = cnx.find('TestConfig', name='tc_quick').one()
+            te = tc.start(pe, branch=u'default')
             cnx.commit()
             te.cw_adapt_to('IWorkflowable').fire_transition('start')
             cnx.commit()
             te.cw_adapt_to('IWorkflowable').fire_transition('fail')
             cnx.commit()
-            #the status should not be waiting execution !
-            self.assertNotEqual(u'waiting execution', te.status)
+            self.assertEqual(u'error', te.status)
 
 
 class ComputedStartModeTC(ApycotBaseTC):