def test_past_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'),
)
with freeze_time(phase1.start_date):
assert list(models.Phase.objects.past_phases()) == []
with freeze_time(phase1.end_date):
assert list(models.Phase.objects.past_phases()) == [phase1]
with freeze_time(phase2.end_date):
assert list(models.Phase.objects.past_phases()) == [phase1, phase2]
评论列表
文章目录