[test] Make test_undo_api less random
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 16 Sep 2014 18:01:51 +0200
changeset 9948 798ab1216523
parent 9911 ea3dcb43b258
child 9949 e0f1c5697221
[test] Make test_undo_api less random The order in which hooks are run is not predictable if they have the same 'order' attribute, which is the case for SetOwnershipHook and SetInitialStateHook. So don't assume in_state will be set before created_by.
server/test/unittest_undo.py
--- a/server/test/unittest_undo.py	Wed Jul 09 16:35:02 2014 +0200
+++ b/server/test/unittest_undo.py	Tue Sep 16 18:01:51 2014 +0200
@@ -104,13 +104,20 @@
             self.assertEqual(a4.eid_from, self.totoeid)
             self.assertEqual(a4.eid_to, self.toto(cnx).in_group[0].eid)
             self.assertEqual(a4.order, 4)
-            for i, rtype in ((1, 'owned_by'), (2, 'owned_by'),
-                             (4, 'in_state'), (5, 'created_by')):
+            for i, rtype in ((1, 'owned_by'), (2, 'owned_by')):
                 a = actions[i]
                 self.assertEqual(a.action, 'A')
                 self.assertEqual(a.eid_from, self.totoeid)
                 self.assertEqual(a.rtype, rtype)
                 self.assertEqual(a.order, i+1)
+            self.assertEqual(set((actions[4].rtype, actions[5].rtype)),
+                             set(('in_state', 'created_by')))
+            for i in (4, 5):
+                a = actions[i]
+                self.assertEqual(a.action, 'A')
+                self.assertEqual(a.eid_from, self.totoeid)
+                self.assertEqual(a.order, i+1)
+
             # test undoable_transactions
             txs = cnx.undoable_transactions()
             self.assertEqual(len(txs), 1)