Commits

Olemis Lang committed 5f26eb9

Trac RPC [ refs rpc-307 ] Test that ticket.update when and author args override arguments supplied in to admin.exec_as

Comments (0)

Files changed (1)

trunk/tracrpc/tests/admin.py

                                               'params' : ["create_at_time3",
                                                           "ok", {}, False,
                                                           xmlrpclib.DateTime(minus2)
-                                                         ]}],
-                                            'auser', xmlrpclib.DateTime(minus1))
+                                                         ]}
+                                            ], 'auser', xmlrpclib.DateTime(minus1))
         self.assertTrue(all(not isinstance(x, xmlrpclib.Fault) for x in (one, two)))
         one, = one
         two, = two
         self.admin.ticket.delete(one)
         self.admin.ticket.delete(two)
 
-#    def test_update_at_time(self):
-#        from trac.util.datefmt import to_datetime, utc
-#        now = to_datetime(None, utc)
-#        minus1 = now - datetime.timedelta(hours=1)
-#        minus2 = now - datetime.timedelta(hours=2)
-#        tid = self.admin.ticket.create("ticket_update_at_time", "ok", {})
-#        self.admin.ticket.update(tid, 'one', {}, False, '', 
-#                                 xmlrpclib.DateTime(minus2))
-#        self.admin.ticket.update(tid, 'two', {}, False, '',
-#                                 xmlrpclib.DateTime(minus1))
-#        self.user.ticket.update(tid, 'three', {}, False, '',
-#                                xmlrpclib.DateTime(minus1))
-#        time.sleep(1)
-#        self.user.ticket.update(tid, 'four', {})
-#        changes = self.admin.ticket.changeLog(tid)
-#        self.assertEquals(4, len(changes))
-#        # quick test to make sure each is older than previous
-#        self.assertTrue(changes[0][0] < changes[1][0] < changes[2][0])
-#        # margin of 2 seconds for tests
-#        justnow = xmlrpclib.DateTime(now - datetime.timedelta(seconds=1))
-#        self.assertTrue(justnow <= changes[2][0])
-#        self.assertTrue(justnow <= changes[3][0])
-#        self.admin.ticket.delete(tid)
-#
+    def test_update_at_time(self):
+        from trac.util.datefmt import to_datetime, utc
+        now = to_datetime(None, utc)
+        minus1 = now - datetime.timedelta(hours=1)
+        minus2 = now - datetime.timedelta(hours=2)
+        minus3 = now - datetime.timedelta(minutes=3)
+        tid = self.admin.ticket.create("ticket_update_at_time", "ok", {})
+        self.admin.admin.exec_as([{'methodName' : 'ticket.update',
+                                  'params' : [tid, 'one', {}, False, '',
+                                              xmlrpclib.DateTime(minus2)]},
+                                  {'methodName' : 'ticket.update',
+                                   'params' : [tid, 'two', {}, False, '',
+                                              xmlrpclib.DateTime(minus1)]},
+                                  {'methodName' : 'ticket.update',
+                                   'params' : [tid, 'three', {}, False, 'usr']
+                                   }], 'auser', minus3)
+        self.user.ticket.update(tid, 'four', {})
+        changes = self.admin.ticket.changeLog(tid)
+        self.assertEquals(4, len(changes))
+        # quick test to make sure each is older than previous
+        self.assertTrue(changes[0][0] < changes[1][0] < changes[2][0])
+        # assertions for user names
+        self.assertEquals('auser', changes[0][1])
+        self.assertEquals('auser', changes[1][1])
+        self.assertEquals('usr', changes[2][1])
+        self.assertEquals('user', changes[3][1])
+        # margin of 2 seconds for tests
+        justnow = xmlrpclib.DateTime(now - datetime.timedelta(minutes=4))
+        self.assertTrue(justnow <= changes[2][0])
+        self.assertTrue(justnow <= changes[3][0])
+        self.admin.ticket.delete(tid)
+
 #    def test_update_basic(self):
 #        import time
 #        # Basic update check, no 'action' or 'time_changed'