Example #1
0
def test_serialize_interval_schedule(interval_schedule):
    schema = schemas.IntervalScheduleSchema()
    assert schema.dump(interval_schedule) == {
        "start_date": serialize_fmt(interval_schedule.start_date),
        "end_date": serialize_fmt(interval_schedule.end_date),
        "interval": int(interval_schedule.interval.total_seconds()) * 1000000,
        "__version__": __version__,
    }
Example #2
0
def test_serialize_interval_at_annual_resolution():
    schedule = schedules.IntervalSchedule(
        start_date=pendulum.now("utc"),
        interval=datetime.timedelta(days=365, microseconds=1),
    )
    schema = schemas.IntervalScheduleSchema()
    serialized = schema.dump(schedule)
    assert serialized["interval"] == 31536000000001
Example #3
0
def test_deserialize_schedule_with_overridden_interval():
    schedule = schedules.IntervalSchedule(
        start_date=pendulum.now("utc"), interval=datetime.timedelta(minutes=1))
    schedule.interval = datetime.timedelta(microseconds=1)
    schema = schemas.IntervalScheduleSchema()
    serialized = schema.dump(schedule)
    assert serialized["interval"] == 1

    with pytest.raises(ValueError) as exc:
        schema.load(serialized)
    assert "Interval can not be less than one minute." in str(exc.value)