コード例 #1
0
 def test_update_time_changed(self):
     # Update with collision check
     import datetime
     from tracrpc.util import to_utimestamp
     from tracrpc.xml_rpc import from_xmlrpc_datetime
     tid = self.admin.ticket.create('test_update_time_changed', '...', {})
     tid, created, modified, attrs = self.admin.ticket.get(tid)
     then = from_xmlrpc_datetime(modified) - datetime.timedelta(minutes=1)
     # Unrestricted old-style update (to be removed soon)
     try:
         self.admin.ticket.update(tid, "comment1",
                 {'_ts': str(to_utimestamp(then))})
     except Exception, e:
         self.assertTrue("Ticket has been updated since last get" in str(e))
コード例 #2
0
 def test_update_time_changed(self):
     # Update with collision check
     import datetime
     from tracrpc.util import to_utimestamp
     from tracrpc.xml_rpc import from_xmlrpc_datetime
     tid = self.admin.ticket.create('test_update_time_changed', '...', {})
     tid, created, modified, attrs = self.admin.ticket.get(tid)
     then = from_xmlrpc_datetime(modified) - datetime.timedelta(minutes=1)
     # Unrestricted old-style update (to be removed soon)
     try:
         self.admin.ticket.update(tid, "comment1",
                 {'_ts': str(to_utimestamp(then))})
     except Exception, e:
         self.assertTrue("Ticket has been updated since last get" in str(e))
コード例 #3
0
ファイル: xml_rpc.py プロジェクト: jun66j5/xmlrpcplugin
 def test_to_and_from_datetime(self):
     from datetime import datetime
     from trac.util.datefmt import to_datetime, utc
     from tracrpc.xml_rpc import to_xmlrpc_datetime, from_xmlrpc_datetime
     now = to_datetime(None, utc)
     now_timetuple = now.timetuple()[:6]
     xmlrpc_now = to_xmlrpc_datetime(now)
     self.assertTrue(isinstance(xmlrpc_now, xmlrpclib.DateTime),
                     "Expected xmlprc_now to be an xmlrpclib.DateTime")
     self.assertEquals(str(xmlrpc_now), now.strftime("%Y%m%dT%H:%M:%S"))
     now_from_xmlrpc = from_xmlrpc_datetime(xmlrpc_now)
     self.assertTrue(isinstance(now_from_xmlrpc, datetime),
                     "Expected now_from_xmlrpc to be a datetime")
     self.assertEquals(now_from_xmlrpc.timetuple()[:6], now_timetuple)
     self.assertEquals(now_from_xmlrpc.tzinfo, utc)
コード例 #4
0
ファイル: xml_rpc.py プロジェクト: Puppet-Finland/trac
 def test_to_and_from_datetime(self):
     from datetime import datetime
     from trac.util.datefmt import to_datetime, utc
     from tracrpc.xml_rpc import to_xmlrpc_datetime, from_xmlrpc_datetime
     now = to_datetime(None, utc)
     now_timetuple = now.timetuple()[:6]
     xmlrpc_now = to_xmlrpc_datetime(now)
     self.assertTrue(isinstance(xmlrpc_now, xmlrpclib.DateTime),
             "Expected xmlprc_now to be an xmlrpclib.DateTime")
     self.assertEquals(str(xmlrpc_now), now.strftime("%Y%m%dT%H:%M:%S"))
     now_from_xmlrpc = from_xmlrpc_datetime(xmlrpc_now)
     self.assertTrue(isinstance(now_from_xmlrpc, datetime),
             "Expected now_from_xmlrpc to be a datetime")
     self.assertEquals(now_from_xmlrpc.timetuple()[:6], now_timetuple)
     self.assertEquals(now_from_xmlrpc.tzinfo, utc)