def test_future_phases(phase_factory):
phase1 = phase_factory(
start_date=parse('2013-01-01 18:00:00 UTC'),
end_date=parse('2013-01-10 18:00:00 UTC'),
)
phase2 = phase_factory(
start_date=parse('2013-01-05 18:00:00 UTC'),
end_date=parse('2013-01-15 18:00:00 UTC'),
)
phase3 = phase_factory(
start_date=None,
end_date=None
)
with freeze_time(phase1.start_date - timedelta(minutes=1)):
assert (list(models.Phase.objects.future_phases())
== [phase3, phase1, phase2])
with freeze_time(phase2.start_date - timedelta(minutes=1)):
assert list(models.Phase.objects.future_phases()) == [phase3, phase2]
with freeze_time(phase2.end_date):
assert list(models.Phase.objects.future_phases()) == [phase3]
评论列表
文章目录