def test_decode_microseconds(self): self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16.123456Z')), datetime(1970, 2, 1, 12, 14, 16, 123456, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16.000123Z')), datetime(1970, 2, 1, 12, 14, 16, 123, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16.000123+0200')), datetime(1970, 2, 1, 12, 14, 16, 123, tzinfo=pytz.FixedOffset(120)))
def get_domain_by_handle(self, handle): print("{}.get_domain_by_handle({})".format(self.__class__.__name__, handle)) if handle == 'kochanski.cz': raise OBJECT_NOT_FOUND() return Domain(handle, 'LISTER', [], None, None, 'REGGIE', [], IsoDateTime('1970-01-01T00:00:00Z'), None, None, IsoDate('2030-01-01'), IsoDateTime('2030-01-01T00:00:00Z'), None, None, None, None)
def _get_domain(self, **kwargs): obj = Domain(handle='fred.cz', registrant_handle='KONTAKT', admin_contact_handles=['KONTAKT'], nsset_handle='NSSET-1', keyset_handle='KEYSID-1', registrar_handle='REG-FRED_A', statuses=[], registered=IsoDateTime('2015-12-09T16:16:30Z'), changed=IsoDateTime('2015-12-10T17:17:31Z'), last_transfer=IsoDateTime('2015-12-11T18:18:32Z'), expire=IsoDate('2018-12-09'), expire_time_estimate=IsoDate('2018-12-09'), expire_time_actual=None, validated_to=None, validated_to_time_estimate=None, validated_to_time_actual=None) field_names = obj.__dict__.keys() for key, value in kwargs.items(): assert key in field_names, "Unknown arg '%s' in _get_domain." % key setattr(obj, key, value) return obj
def encode_iso_date(value): """Encode date object into IsoDate struct.""" return IsoDate(value.isoformat())
def test_decode_zones(self): self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+0000')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+00:00')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16-0000')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16-00:00')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.utc)) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+0005')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(5))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+0020')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(20))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+0100')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(60))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+1000')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(600))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+10:00')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(600))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16-1000')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(-600))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16-10:00')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(-600))) self.assertEqual( decode_iso_datetime(IsoDate('1970-02-01T12:14:16+1135')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.FixedOffset(695)))
def test_decode(self): self.assertEqual(decode_iso_datetime(IsoDate('1970-02-01T12:14:16Z')), datetime(1970, 2, 1, 12, 14, 16, tzinfo=pytz.utc))
def test_encode(self): self.assertEqual(encode_iso_date(date(1970, 2, 1)), IsoDate('1970-02-01'))
def test_decode(self): self.assertEqual(decode_iso_date(IsoDate('1970-02-01')), date(1970, 2, 1))