Ejemplo n.º 1
0
 def test_utc_date_time_deserialize(self):
     """
     UTCDateTimeAttribute.deserialize
     """
     tstamp = datetime.now(UTC)
     attr = UTCDateTimeAttribute()
     assert attr.deserialize(tstamp.strftime(DATETIME_FORMAT)) == tstamp
Ejemplo n.º 2
0
 def test_utc_date_time_serialize(self):
     """
     UTCDateTimeAttribute.serialize
     """
     tstamp = datetime.now()
     attr = UTCDateTimeAttribute()
     assert attr.serialize(tstamp) == tstamp.replace(
         tzinfo=UTC).strftime(DATETIME_FORMAT)
Ejemplo n.º 3
0
 def test_dateutil_parser_fallback(self):
     """
     UTCDateTimeAttribute.deserialize
     """
     expected_value = datetime(2047, 1, 6, 8, 21, tzinfo=tzutc())
     attr = UTCDateTimeAttribute()
     assert attr.deserialize(
         'January 6, 2047 at 8:21:00AM UTC') == expected_value
Ejemplo n.º 4
0
 def test_utc_datetime_attribute(self):
     """
     UTCDateTimeAttribute.default
     """
     attr = UTCDateTimeAttribute()
     assert attr is not None
     assert attr.attr_type == STRING
     tstamp = datetime.now()
     attr = UTCDateTimeAttribute(default=tstamp)
     assert attr.default == tstamp
Ejemplo n.º 5
0
    def test_utc_date_time_deserialize_parse_args(self, parse_mock,
                                                  datetime_mock):
        """
        UTCDateTimeAttribute.deserialize
        """
        tstamp = datetime.now(UTC)
        attr = UTCDateTimeAttribute()

        tstamp_str = tstamp.strftime(DATETIME_FORMAT)
        attr.deserialize(tstamp_str)

        parse_mock.assert_not_called()
        datetime_mock.strptime.assert_called_once_with(tstamp_str,
                                                       DATETIME_FORMAT)
Ejemplo n.º 6
0
class AttributeTestModel(Model):
    class Meta:
        host = 'http://localhost:8000'
        table_name = 'test'

    binary_attr = BinaryAttribute()
    binary_set_attr = BinarySetAttribute()
    number_attr = NumberAttribute()
    number_set_attr = NumberSetAttribute()
    unicode_attr = UnicodeAttribute()
    unicode_set_attr = UnicodeSetAttribute()
    datetime_attr = UTCDateTimeAttribute()
    bool_attr = BooleanAttribute()
    json_attr = JSONAttribute()
    map_attr = MapAttribute()
Ejemplo n.º 7
0
 class CustomMapAttribute(MapAttribute):
     date_attr = UTCDateTimeAttribute()