Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def test_parses_null_datetime(self):
     assert JSTimestampField()._serialize(None, None, None) is None
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
class WorkspaceDurationSchema(Schema):
    start_date = JSTimestampField(attribute='start_date')
    end_date = JSTimestampField(attribute='end_date')