示例#1
0
 def test_deserialization_fails(self):
     ts = time.time()
     dt = datetime.datetime.fromtimestamp(ts)
     loaded = JSTimestampField()._deserialize(ts * 1000,
                                              None,
                                              None)
     assert isinstance(loaded, datetime.date)
     assert abs(loaded - dt) < datetime.timedelta(seconds=60)
示例#2
0
class WorkspaceDurationSchema(Schema):
    start_date = JSTimestampField(attribute='start_date')
    end_date = JSTimestampField(attribute='end_date')
示例#3
0
 def test_parses_null_datetime(self):
     assert JSTimestampField()._serialize(None, None, None) is None
示例#4
0
 def test_parses_current_datetime(self):
     ts = time.time()
     dt = datetime.datetime.fromtimestamp(ts)
     parsed = JSTimestampField()._serialize(dt, None, None)
     assert parsed == int(ts) * 1000
     assert isinstance(parsed, int)