Fix remaining DST error in auto check-out

This commit is contained in:
Raphael Michel
2021-11-03 09:33:58 +01:00
parent ea6067ab3f
commit 0c508c5ba4
2 changed files with 25 additions and 3 deletions

View File

@@ -822,6 +822,17 @@ def test_auto_check_out_only_if_checked_in(event, position, clist):
assert position.checkins.count() == 2
@pytest.mark.django_db(transaction=True)
def test_auto_check_out_only_if_checked_in_before_exit_all_at(event, position, clist):
clist.exit_all_at = event.timezone.localize(datetime(2020, 1, 2, 3, 0))
clist.save()
with freeze_time("2020-01-02 04:05:00+01:00"):
perform_checkin(position, clist, {})
process_exit_all(sender=None)
assert position.checkins.count() == 1
@pytest.mark.django_db(transaction=True)
def test_auto_check_out_dst(event, position, clist):
event.settings.timezone = 'Europe/Berlin'
@@ -835,12 +846,16 @@ def test_auto_check_out_dst(event, position, clist):
assert clist.exit_all_at.astimezone(event.timezone) == event.timezone.localize(datetime(2021, 3, 29, 1, 0))
# Survive across a shift that makes the time in question ambigous
clist.exit_all_at = event.timezone.localize(datetime(2021, 10, 28, 2, 30))
clist.exit_all_at = event.timezone.localize(datetime(2021, 10, 30, 2, 30))
clist.save()
with freeze_time(clist.exit_all_at + timedelta(minutes=5)):
process_exit_all(sender=None)
clist.refresh_from_db()
assert clist.exit_all_at.astimezone(event.timezone) == event.timezone.localize(datetime(2021, 10, 29, 2, 30))
assert clist.exit_all_at.astimezone(event.timezone) == event.timezone.localize(datetime(2021, 10, 31, 2, 30))
with freeze_time(clist.exit_all_at + timedelta(minutes=5)):
process_exit_all(sender=None)
clist.refresh_from_db()
assert clist.exit_all_at.astimezone(event.timezone) == event.timezone.localize(datetime(2021, 11, 1, 2, 30))
# Doesn't survive across a shift that makes the time in question non-existant
clist.exit_all_at = event.timezone.localize(datetime(2021, 3, 27, 2, 30))