server/test/unittest_undo.py
branchstable
changeset 6340 470d8e828fda
parent 5762 730d458ec1bf
child 6796 e70ca9abfc51
--- a/server/test/unittest_undo.py	Fri Sep 24 18:20:57 2010 +0200
+++ b/server/test/unittest_undo.py	Fri Sep 24 18:20:59 2010 +0200
@@ -54,36 +54,36 @@
                           self.cnx.undo_transaction, 'hop')
         txinfo = self.cnx.transaction_info(self.txuuid)
         self.failUnless(txinfo.datetime)
-        self.assertEquals(txinfo.user_eid, self.session.user.eid)
-        self.assertEquals(txinfo.user().login, 'admin')
+        self.assertEqual(txinfo.user_eid, self.session.user.eid)
+        self.assertEqual(txinfo.user().login, 'admin')
         actions = txinfo.actions_list()
-        self.assertEquals(len(actions), 2)
+        self.assertEqual(len(actions), 2)
         actions = txinfo.actions_list(public=False)
-        self.assertEquals(len(actions), 6)
+        self.assertEqual(len(actions), 6)
         a1 = actions[0]
-        self.assertEquals(a1.action, 'C')
-        self.assertEquals(a1.eid, self.toto.eid)
-        self.assertEquals(a1.etype,'CWUser')
-        self.assertEquals(a1.changes, None)
-        self.assertEquals(a1.public, True)
-        self.assertEquals(a1.order, 1)
+        self.assertEqual(a1.action, 'C')
+        self.assertEqual(a1.eid, self.toto.eid)
+        self.assertEqual(a1.etype,'CWUser')
+        self.assertEqual(a1.changes, None)
+        self.assertEqual(a1.public, True)
+        self.assertEqual(a1.order, 1)
         a4 = actions[3]
-        self.assertEquals(a4.action, 'A')
-        self.assertEquals(a4.rtype, 'in_group')
-        self.assertEquals(a4.eid_from, self.toto.eid)
-        self.assertEquals(a4.eid_to, self.toto.in_group[0].eid)
-        self.assertEquals(a4.order, 4)
+        self.assertEqual(a4.action, 'A')
+        self.assertEqual(a4.rtype, 'in_group')
+        self.assertEqual(a4.eid_from, self.toto.eid)
+        self.assertEqual(a4.eid_to, self.toto.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')):
             a = actions[i]
-            self.assertEquals(a.action, 'A')
-            self.assertEquals(a.eid_from, self.toto.eid)
-            self.assertEquals(a.rtype, rtype)
-            self.assertEquals(a.order, i+1)
+            self.assertEqual(a.action, 'A')
+            self.assertEqual(a.eid_from, self.toto.eid)
+            self.assertEqual(a.rtype, rtype)
+            self.assertEqual(a.order, i+1)
         # test undoable_transactions
         txs = self.cnx.undoable_transactions()
-        self.assertEquals(len(txs), 1)
-        self.assertEquals(txs[0].uuid, self.txuuid)
+        self.assertEqual(len(txs), 1)
+        self.assertEqual(txs[0].uuid, self.txuuid)
         # test transaction_info / undoable_transactions security
         cnx = self.login('anon')
         self.assertRaises(NoSuchTransaction,
@@ -93,7 +93,7 @@
         self.assertRaises(NoSuchTransaction,
                           cnx.undo_transaction, self.txuuid)
         txs = cnx.undoable_transactions()
-        self.assertEquals(len(txs), 0)
+        self.assertEqual(len(txs), 0)
 
     def test_undoable_transactions(self):
         toto = self.toto
@@ -105,31 +105,31 @@
         txuuid2 = self.commit()
         undoable_transactions = self.cnx.undoable_transactions
         txs = undoable_transactions(action='D')
-        self.assertEquals(len(txs), 1, txs)
-        self.assertEquals(txs[0].uuid, txuuid2)
+        self.assertEqual(len(txs), 1, txs)
+        self.assertEqual(txs[0].uuid, txuuid2)
         txs = undoable_transactions(action='C')
-        self.assertEquals(len(txs), 2, txs)
-        self.assertEquals(txs[0].uuid, txuuid1)
-        self.assertEquals(txs[1].uuid, self.txuuid)
+        self.assertEqual(len(txs), 2, txs)
+        self.assertEqual(txs[0].uuid, txuuid1)
+        self.assertEqual(txs[1].uuid, self.txuuid)
         txs = undoable_transactions(eid=toto.eid)
-        self.assertEquals(len(txs), 3)
-        self.assertEquals(txs[0].uuid, txuuid2)
-        self.assertEquals(txs[1].uuid, txuuid1)
-        self.assertEquals(txs[2].uuid, self.txuuid)
+        self.assertEqual(len(txs), 3)
+        self.assertEqual(txs[0].uuid, txuuid2)
+        self.assertEqual(txs[1].uuid, txuuid1)
+        self.assertEqual(txs[2].uuid, self.txuuid)
         txs = undoable_transactions(etype='CWUser')
-        self.assertEquals(len(txs), 2)
+        self.assertEqual(len(txs), 2)
         txs = undoable_transactions(etype='CWUser', action='C')
-        self.assertEquals(len(txs), 1)
-        self.assertEquals(txs[0].uuid, self.txuuid)
+        self.assertEqual(len(txs), 1)
+        self.assertEqual(txs[0].uuid, self.txuuid)
         txs = undoable_transactions(etype='EmailAddress', action='D')
-        self.assertEquals(len(txs), 0)
+        self.assertEqual(len(txs), 0)
         txs = undoable_transactions(etype='EmailAddress', action='D',
                                     public=False)
-        self.assertEquals(len(txs), 1)
-        self.assertEquals(txs[0].uuid, txuuid2)
+        self.assertEqual(len(txs), 1)
+        self.assertEqual(txs[0].uuid, txuuid2)
         txs = undoable_transactions(eid=toto.eid, action='R', public=False)
-        self.assertEquals(len(txs), 1)
-        self.assertEquals(txs[0].uuid, txuuid2)
+        self.assertEqual(len(txs), 1)
+        self.assertEqual(txs[0].uuid, txuuid2)
 
     def test_undo_deletion_base(self):
         toto = self.toto
@@ -143,34 +143,34 @@
                                        for_user=toto)
         self.commit()
         txs = self.cnx.undoable_transactions()
-        self.assertEquals(len(txs), 2)
+        self.assertEqual(len(txs), 2)
         toto.cw_delete()
         txuuid = self.commit()
         actions = self.cnx.transaction_info(txuuid).actions_list()
-        self.assertEquals(len(actions), 1)
+        self.assertEqual(len(actions), 1)
         toto.clear_all_caches()
         e.clear_all_caches()
         errors = self.cnx.undo_transaction(txuuid)
         undotxuuid = self.commit()
-        self.assertEquals(undotxuuid, None) # undo not undoable
-        self.assertEquals(errors, [])
+        self.assertEqual(undotxuuid, None) # undo not undoable
+        self.assertEqual(errors, [])
         self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': toto.eid}))
         self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': e.eid}))
         self.failUnless(self.execute('Any X WHERE X has_text "toto@logilab"'))
-        self.assertEquals(toto.cw_adapt_to('IWorkflowable').state, 'activated')
-        self.assertEquals(toto.cw_adapt_to('IEmailable').get_email(), 'toto@logilab.org')
-        self.assertEquals([(p.pkey, p.value) for p in toto.reverse_for_user],
+        self.assertEqual(toto.cw_adapt_to('IWorkflowable').state, 'activated')
+        self.assertEqual(toto.cw_adapt_to('IEmailable').get_email(), 'toto@logilab.org')
+        self.assertEqual([(p.pkey, p.value) for p in toto.reverse_for_user],
                           [('ui.default-text-format', 'text/rest')])
-        self.assertEquals([g.name for g in toto.in_group],
+        self.assertEqual([g.name for g in toto.in_group],
                           ['users'])
-        self.assertEquals([et.name for et in toto.related('is', entities=True)],
+        self.assertEqual([et.name for et in toto.related('is', entities=True)],
                           ['CWUser'])
-        self.assertEquals([et.name for et in toto.is_instance_of],
+        self.assertEqual([et.name for et in toto.is_instance_of],
                           ['CWUser'])
         # undoing shouldn't be visble in undoable transaction, and the undoed
         # transaction should be removed
         txs = self.cnx.undoable_transactions()
-        self.assertEquals(len(txs), 2)
+        self.assertEqual(len(txs), 2)
         self.assertRaises(NoSuchTransaction,
                           self.cnx.transaction_info, txuuid)
         self.check_transaction_deleted(txuuid)
@@ -191,9 +191,9 @@
         errors = self.cnx.undo_transaction(txuuid)
         self.commit()
         p.clear_all_caches()
-        self.assertEquals(p.fiche[0].eid, c2.eid)
-        self.assertEquals(len(errors), 1)
-        self.assertEquals(errors[0],
+        self.assertEqual(p.fiche[0].eid, c2.eid)
+        self.assertEqual(len(errors), 1)
+        self.assertEqual(errors[0],
                           "Can't restore object relation fiche to entity "
                           "%s which is already linked using this relation." % p.eid)
 
@@ -209,12 +209,12 @@
         g.cw_delete()
         self.commit()
         errors = self.cnx.undo_transaction(txuuid)
-        self.assertEquals(errors,
+        self.assertEqual(errors,
                           [u"Can't restore relation in_group, object entity "
                           "%s doesn't exist anymore." % g.eid])
         ex = self.assertRaises(ValidationError, self.commit)
-        self.assertEquals(ex.entity, self.toto.eid)
-        self.assertEquals(ex.errors,
+        self.assertEqual(ex.entity, self.toto.eid)
+        self.assertEqual(ex.errors,
                           {'in_group-subject': u'at least one relation in_group is '
                            'required on CWUser (%s)' % self.toto.eid})
 
@@ -254,8 +254,8 @@
         self.commit()
         ex = self.assertRaises(ValidationError,
                                self.cnx.undo_transaction, txuuid)
-        self.assertEquals(ex.entity, tutu.eid)
-        self.assertEquals(ex.errors,
+        self.assertEqual(ex.entity, tutu.eid)
+        self.assertEqual(ex.errors,
                           {None: 'some later transaction(s) touch entity, undo them first'})
 
     def test_undo_creation_integrity_2(self):
@@ -267,15 +267,15 @@
         self.commit()
         ex = self.assertRaises(ValidationError,
                                self.cnx.undo_transaction, txuuid)
-        self.assertEquals(ex.entity, g.eid)
-        self.assertEquals(ex.errors,
+        self.assertEqual(ex.entity, g.eid)
+        self.assertEqual(ex.errors,
                           {None: 'some later transaction(s) touch entity, undo them first'})
-        # self.assertEquals(errors,
+        # self.assertEqual(errors,
         #                   [u"Can't restore relation in_group, object entity "
         #                   "%s doesn't exist anymore." % g.eid])
         # ex = self.assertRaises(ValidationError, self.commit)
-        # self.assertEquals(ex.entity, self.toto.eid)
-        # self.assertEquals(ex.errors,
+        # self.assertEqual(ex.entity, self.toto.eid)
+        # self.assertEqual(ex.errors,
         #                   {'in_group-subject': u'at least one relation in_group is '
         #                    'required on CWUser (%s)' % self.toto.eid})