Python xmlrpc.client.DateTime() Examples
The following are 30
code examples of xmlrpc.client.DateTime().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xmlrpc.client
, or try the search function
.
Example #1
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_datetime_before_1900(self): # same as before but with a date before 1900 dt = datetime.datetime(1, 2, 10, 11, 41, 23) self.assertEqual(dt, xmlrpclib.DateTime('00010210T11:41:23')) s = xmlrpclib.dumps((dt,)) result, m = xmlrpclib.loads(s, use_builtin_types=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_builtin_types=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m)
Example #2
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_datetime_before_1900(self): # same as before but with a date before 1900 dt = datetime.datetime(1, 2, 10, 11, 41, 23) self.assertEqual(dt, xmlrpclib.DateTime('00010210T11:41:23')) s = xmlrpclib.dumps((dt,)) result, m = xmlrpclib.loads(s, use_builtin_types=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_builtin_types=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m)
Example #3
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_datetime_before_1900(self): # same as before but with a date before 1900 dt = datetime.datetime(1, 2, 10, 11, 41, 23) self.assertEqual(dt, xmlrpclib.DateTime('00010210T11:41:23')) s = xmlrpclib.dumps((dt,)) result, m = xmlrpclib.loads(s, use_builtin_types=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_builtin_types=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m)
Example #4
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_time_struct(self): d = time.localtime(1181399930.036952) t = xmlrpclib.DateTime(d) self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
Example #5
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_repr(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) val ="<DateTime '20070102T03:04:05' at %x>" % id(t) self.assertEqual(repr(t), val)
Example #6
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_decode(self): d = ' 20070908T07:11:13 ' t1 = xmlrpclib.DateTime() t1.decode(d) tref = xmlrpclib.DateTime(datetime.datetime(2007,9,8,7,11,13)) self.assertEqual(t1, tref) t2 = xmlrpclib._datetime(d) self.assertEqual(t2, tref)
Example #7
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_comparison(self): now = datetime.datetime.now() dtime = xmlrpclib.DateTime(now.timetuple()) # datetime vs. DateTime self.assertTrue(dtime == now) self.assertTrue(now == dtime) then = now + datetime.timedelta(seconds=4) self.assertTrue(then >= dtime) self.assertTrue(dtime < then) # str vs. DateTime dstr = now.strftime("%Y%m%dT%H:%M:%S") self.assertTrue(dtime == dstr) self.assertTrue(dstr == dtime) dtime_then = xmlrpclib.DateTime(then.timetuple()) self.assertTrue(dtime_then >= dstr) self.assertTrue(dstr < dtime_then) # some other types dbytes = dstr.encode('ascii') dtuple = now.timetuple() with self.assertRaises(TypeError): dtime == 1970 with self.assertRaises(TypeError): dtime != dbytes with self.assertRaises(TypeError): dtime == bytearray(dbytes) with self.assertRaises(TypeError): dtime != dtuple with self.assertRaises(TypeError): dtime < float(1970) with self.assertRaises(TypeError): dtime > dbytes with self.assertRaises(TypeError): dtime <= bytearray(dbytes) with self.assertRaises(TypeError): dtime >= dtuple
Example #8
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_dump_bare_datetime(self): # This checks that an unwrapped datetime.date object can be handled # by the marshalling code. This can't be done via test_dump_load() # since with use_builtin_types set to 1 the unmarshaller would create # datetime objects for the 'datetime[123]' keys as well dt = datetime.datetime(2005, 2, 10, 11, 41, 23) self.assertEqual(dt, xmlrpclib.DateTime('20050210T11:41:23')) s = xmlrpclib.dumps((dt,)) result, m = xmlrpclib.loads(s, use_builtin_types=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_builtin_types=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_datetime=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_datetime=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m)
Example #9
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_bug_1164912 (self): d = xmlrpclib.DateTime() ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,), methodresponse=True)) self.assertIsInstance(new_d.value, str) # Check that the output of dumps() is still an 8-bit string s = xmlrpclib.dumps((new_d,), methodresponse=True) self.assertIsInstance(s, str)
Example #10
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_default(self): with mock.patch('time.localtime') as localtime_mock: time_struct = time.struct_time( [2013, 7, 15, 0, 24, 49, 0, 196, 0]) localtime_mock.return_value = time_struct localtime = time.localtime() t = xmlrpclib.DateTime() self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", localtime))
Example #11
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_time(self): d = 1181399930.036952 t = xmlrpclib.DateTime(d) self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d)))
Example #12
Source File: test_msgpackutils.py From oslo.serialization with Apache License 2.0 | 5 votes |
def test_datetime(self): x = xmlrpclib.DateTime() x.decode("19710203T04:05:06") self.assertEqual(x, _dumps_loads(x))
Example #13
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_datetime_datetime(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) self.assertEqual(str(t), '20070102T03:04:05')
Example #14
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_repr(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) val ="<DateTime '20070102T03:04:05' at %#x>" % id(t) self.assertEqual(repr(t), val)
Example #15
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_decode(self): d = ' 20070908T07:11:13 ' t1 = xmlrpclib.DateTime() t1.decode(d) tref = xmlrpclib.DateTime(datetime.datetime(2007,9,8,7,11,13)) self.assertEqual(t1, tref) t2 = xmlrpclib._datetime(d) self.assertEqual(t2, tref)
Example #16
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_comparison(self): now = datetime.datetime.now() dtime = xmlrpclib.DateTime(now.timetuple()) # datetime vs. DateTime self.assertTrue(dtime == now) self.assertTrue(now == dtime) then = now + datetime.timedelta(seconds=4) self.assertTrue(then >= dtime) self.assertTrue(dtime < then) # str vs. DateTime dstr = now.strftime("%Y%m%dT%H:%M:%S") self.assertTrue(dtime == dstr) self.assertTrue(dstr == dtime) dtime_then = xmlrpclib.DateTime(then.timetuple()) self.assertTrue(dtime_then >= dstr) self.assertTrue(dstr < dtime_then) # some other types dbytes = dstr.encode('ascii') dtuple = now.timetuple() with self.assertRaises(TypeError): dtime == 1970 with self.assertRaises(TypeError): dtime != dbytes with self.assertRaises(TypeError): dtime == bytearray(dbytes) with self.assertRaises(TypeError): dtime != dtuple with self.assertRaises(TypeError): dtime < float(1970) with self.assertRaises(TypeError): dtime > dbytes with self.assertRaises(TypeError): dtime <= bytearray(dbytes) with self.assertRaises(TypeError): dtime >= dtuple
Example #17
Source File: _hosting.py From gandi.cli with GNU General Public License v3.0 | 5 votes |
def account_info(): return {'average_credit_cost': 0.0, 'credits': 2335360, 'cycle_day': 23, 'date_credits_expiration': DateTime('20160319T10:07:24'), 'fullname': 'Peter Parker', 'handle': 'PXP561-GANDI', 'id': 2920674, 'products': None, 'rating_enabled': True, 'resources': {'available': None, 'expired': None, 'granted': None, 'used': None}, 'share_definition': None}
Example #18
Source File: _hosting.py From gandi.cli with GNU General Public License v3.0 | 5 votes |
def rating_list(): return [{'bw_out': None, 'cpu': {'default': 168}, 'disk_data': {'default': 135}, 'disk_snapshot': None, 'disk_snapshot_auto': None, 'instance': {'default': 0}, 'ip': {'v4_public': 210, 'v6': 0}, 'ram': {'default': 120}, 'rproxy': None, 'rproxy_server': None, 'rproxy_ssl': None, 'timestamp': DateTime('20150319T15:07:24')}]
Example #19
Source File: _paas.py From gandi.cli with GNU General Public License v3.0 | 5 votes |
def list(options): ret = [{'catalog_name': 'phpmysql_s', 'console': '1656411@console.dc0.gpaas.net', 'data_disk_additional_size': 0, 'datacenter_id': 1, 'date_end': DateTime('20160408T00:00:00'), 'date_end_commitment': None, 'date_start': DateTime('20130903T22:14:13'), 'id': 126276, 'name': 'paas_owncloud', 'need_upgrade': False, 'servers': [{'id': 126273}], 'size': 's', 'snapshot_profile': None, 'state': 'halted', 'type': 'phpmysql'}, {'catalog_name': 'nodejsmongodb_s', 'console': '185290@console.dc2.gpaas.net', 'data_disk_additional_size': 0, 'datacenter_id': 3, 'date_end': DateTime('20161125T15:52:56'), 'date_end_commitment': DateTime('20151118T18:00:00'), 'date_start': DateTime('20141025T15:52:56'), 'id': 163744, 'name': 'paas_cozycloud', 'need_upgrade': False, 'servers': [{'id': 163728}], 'size': 's', 'snapshot_profile': None, 'state': 'running', 'type': 'nodejsmongodb'}] options.pop('items_per_page', None) for fkey in options: ret = [paas for paas in ret if paas[fkey] == options[fkey]] return ret
Example #20
Source File: _paas.py From gandi.cli with GNU General Public License v3.0 | 5 votes |
def vhost_list(options): ret = [{'cert_id': None, 'date_creation': DateTime('20130903T22:11:54'), 'id': 160126, 'name': 'aa3e0e26f8.url-de-test.ws', 'paas_id': 126276, 'state': 'running'}, {'cert_id': None, 'date_creation': DateTime('20130903T22:24:06'), 'id': 160127, 'name': 'cloud.cat.lol', 'paas_id': 126276, 'state': 'running'}, {'cert_id': None, 'date_creation': DateTime('20141025T15:50:54'), 'id': 1177216, 'name': '187832c2b34.testurl.ws', 'paas_id': 163744, 'state': 'running'}, {'cert_id': None, 'date_creation': DateTime('20141025T15:50:54'), 'id': 1177220, 'name': 'cloud.iheartcli.com', 'paas_id': 163744, 'state': 'running'}, {'cert_id': None, 'date_creation': DateTime('20150728T17:50:56'), 'id': 1365951, 'name': 'cli.sexy', 'paas_id': 163744, 'state': 'running'}] options.pop('items_per_page', None) for fkey in options: ret = [paas for paas in ret if paas[fkey] == options[fkey]] return ret
Example #21
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_time_struct(self): d = time.localtime(1181399930.036952) t = xmlrpclib.DateTime(d) self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
Example #22
Source File: msgpackutils.py From oslo.serialization with Apache License 2.0 | 5 votes |
def deserialize(self, blob): dt = self._handler.deserialize(blob) return xmlrpclib.DateTime(dt.timetuple())
Example #23
Source File: test_jsonutils.py From oslo.serialization with Apache License 2.0 | 5 votes |
def test_DateTime(self): x = xmlrpclib.DateTime() x.decode("19710203T04:05:06") self.assertEqual('1971-02-03T04:05:06.000000', jsonutils.to_primitive(x))
Example #24
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_dump_bare_datetime(self): # This checks that an unwrapped datetime.date object can be handled # by the marshalling code. This can't be done via test_dump_load() # since with use_builtin_types set to 1 the unmarshaller would create # datetime objects for the 'datetime[123]' keys as well dt = datetime.datetime(2005, 2, 10, 11, 41, 23) self.assertEqual(dt, xmlrpclib.DateTime('20050210T11:41:23')) s = xmlrpclib.dumps((dt,)) result, m = xmlrpclib.loads(s, use_builtin_types=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_builtin_types=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_datetime=True) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), datetime.datetime) self.assertIsNone(m) result, m = xmlrpclib.loads(s, use_datetime=False) (newdt,) = result self.assertEqual(newdt, dt) self.assertIs(type(newdt), xmlrpclib.DateTime) self.assertIsNone(m)
Example #25
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_bug_1164912 (self): d = xmlrpclib.DateTime() ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,), methodresponse=True)) self.assertIsInstance(new_d.value, str) # Check that the output of dumps() is still an 8-bit string s = xmlrpclib.dumps((new_d,), methodresponse=True) self.assertIsInstance(s, str)
Example #26
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_default(self): with mock.patch('time.localtime') as localtime_mock: time_struct = time.struct_time( [2013, 7, 15, 0, 24, 49, 0, 196, 0]) localtime_mock.return_value = time_struct localtime = time.localtime() t = xmlrpclib.DateTime() self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", localtime))
Example #27
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_time(self): d = 1181399930.036952 t = xmlrpclib.DateTime(d) self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d)))
Example #28
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_time_struct(self): d = time.localtime(1181399930.036952) t = xmlrpclib.DateTime(d) self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
Example #29
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_datetime_datetime(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) self.assertEqual(str(t), '20070102T03:04:05')
Example #30
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_repr(self): d = datetime.datetime(2007,1,2,3,4,5) t = xmlrpclib.DateTime(d) val ="<DateTime '20070102T03:04:05' at %#x>" % id(t) self.assertEqual(repr(t), val)