[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.
--- 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)