Python xmlrpclib.DateTime() Examples

The following are 30 code examples of xmlrpclib.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 xmlrpclib , or try the search function .
Example #1
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_default(self):
        t = xmlrpclib.DateTime() 
Example #2
Source File: _hosting.py    From gandi.cli with GNU General Public License v3.0 5 votes vote down vote up
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 #3
Source File: _hosting.py    From gandi.cli with GNU General Public License v3.0 5 votes vote down vote up
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 #4
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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(t1, tref) 
Example #5
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_cmp_datetime_DateTime(self):
        now = datetime.datetime.now()
        dt = xmlrpclib.DateTime(now.timetuple())
        self.assertTrue(dt == now)
        self.assertTrue(now == dt)
        then = now + datetime.timedelta(seconds=4)
        self.assertTrue(then >= dt)
        self.assertTrue(dt < then) 
Example #6
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 #7
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_default(self):
        t = xmlrpclib.DateTime() 
Example #8
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_time_tuple(self):
        d = (2007,6,9,10,38,50,5,160,0)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), '20070609T10:38:50') 
Example #9
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 #10
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 #11
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 #12
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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(t1, tref) 
Example #13
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23')) 
Example #14
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 #15
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_time_tuple(self):
        d = (2007,6,9,10,38,50,5,160,0)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), '20070609T10:38:50') 
Example #16
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 #17
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 #18
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_cmp_datetime_DateTime(self):
        now = datetime.datetime.now()
        dt = xmlrpclib.DateTime(now.timetuple())
        self.assertTrue(dt == now)
        self.assertTrue(now == dt)
        then = now + datetime.timedelta(seconds=4)
        self.assertTrue(then >= dt)
        self.assertTrue(dt < then) 
Example #19
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23')) 
Example #20
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23')) 
Example #21
Source File: test_xmlrpc.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_bug_1164912 (self):
        d = xmlrpclib.DateTime()
        ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,),
                                            methodresponse=True))
        self.assert_(isinstance(new_d.value, str))

        # Check that the output of dumps() is still an 8-bit string
        s = xmlrpclib.dumps((new_d,), methodresponse=True)
        self.assert_(isinstance(s, str)) 
Example #22
Source File: test_xmlrpc.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_dump_bare_time(self):
        # This checks that an unwrapped datetime.time object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since the unmarshaller produces a datetime object
        t = datetime.datetime(2005, 02, 10, 11, 41, 23).time()
        s = xmlrpclib.dumps((t,))
        (newt,), m = xmlrpclib.loads(s, use_datetime=1)
        today = datetime.datetime.now().date().strftime("%Y%m%d")
        self.assertEquals(newt.time(), t)
        self.assertEquals(newt.date(), datetime.datetime.now().date())
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today)) 
Example #23
Source File: test_xmlrpc.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_dump_bare_date(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 the unmarshaller produces a datetime object
        d = datetime.datetime(2005, 02, 10, 11, 41, 23).date()
        s = xmlrpclib.dumps((d,))
        (newd,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEquals(newd.date(), d)
        self.assertEquals(newd.time(), datetime.time(0, 0, 0))
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00')) 
Example #24
Source File: test_xmlrpc.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEquals(newdt, dt)
        self.assertEquals(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23')) 
Example #25
Source File: test_xmlrpc.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_datetimeRoundtrip(self):
        """
        If an L{xmlrpclib.DateTime} is passed as an argument to an XML-RPC
        call and then returned by the server unmodified, the result should
        be equal to the original object.
        """
        when = xmlrpclib.DateTime()
        d = self.proxy().callRemote("echo", when)
        d.addCallback(self.assertEqual, when)
        return d 
Example #26
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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(t1, tref) 
Example #27
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #28
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #29
Source File: test_xmlrpc.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23')) 
Example #30
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_time_tuple(self):
        d = (2007,6,9,10,38,50,5,160,0)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), '20070609T10:38:50')