Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Use DEADLINE_TZINFO to validate reminder due date calculation #5019

Merged
merged 2 commits into from
Jan 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions ietf/doc/tests_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from ietf.utils.test_utils import login_testing_unauthorized
from ietf.utils.mail import outbox, empty_outbox, get_payload_text
from ietf.utils.test_utils import TestCase
from ietf.utils.timezone import date_today, datetime_from_date
from ietf.utils.timezone import date_today, datetime_from_date, DEADLINE_TZINFO


class ChangeStateTests(TestCase):
Expand Down Expand Up @@ -1749,8 +1749,11 @@ def test_set_initial_state(self):
self.assertEqual(draft.docevent_set.count() - events_before, 2)
reminder = DocReminder.objects.filter(event__doc=draft, type="stream-s")
self.assertEqual(len(reminder), 1)
due = timezone.now() + datetime.timedelta(weeks=10)
self.assertTrue(due - datetime.timedelta(days=1) <= reminder[0].due <= due + datetime.timedelta(days=1))
due = timezone.now().astimezone(DEADLINE_TZINFO) + datetime.timedelta(weeks=10)
self.assertTrue(
due - datetime.timedelta(days=1) <= reminder[0].due <= due + datetime.timedelta(days=1),
f'Due date {reminder[0].due} should be {due} +/- 1 day'
)
self.assertEqual(len(outbox), 1)
self.assertTrue("state changed" in outbox[0]["Subject"].lower())
self.assertTrue("[email protected]" in outbox[0].as_string())
Expand Down Expand Up @@ -1794,8 +1797,11 @@ def test_set_state(self):
self.assertEqual(draft.docevent_set.count() - events_before, 2)
reminder = DocReminder.objects.filter(event__doc=draft, type="stream-s")
self.assertEqual(len(reminder), 1)
due = timezone.now() + datetime.timedelta(weeks=10)
self.assertTrue(due - datetime.timedelta(days=1) <= reminder[0].due <= due + datetime.timedelta(days=1))
due = timezone.now().astimezone(DEADLINE_TZINFO) + datetime.timedelta(weeks=10)
self.assertTrue(
due - datetime.timedelta(days=1) <= reminder[0].due <= due + datetime.timedelta(days=1),
f'Due date {reminder[0].due} should be {due} +/- 1 day'
)
self.assertEqual(len(outbox), 1)
self.assertTrue("state changed" in outbox[0]["Subject"].lower())
self.assertTrue("[email protected]" in outbox[0].as_string())
Expand Down