From 8591e71a4e3fffc01f13c91da10a90425f37e404 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:13:43 -0800 Subject: [PATCH] Fix: fix failing timezone tests --- src/documents/tests/test_api_search.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/documents/tests/test_api_search.py b/src/documents/tests/test_api_search.py index e9ce2fcce..8e4d21fe8 100644 --- a/src/documents/tests/test_api_search.py +++ b/src/documents/tests/test_api_search.py @@ -671,8 +671,8 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase): content="things i paid for in august", pk=2, checksum="B", - # 1 month, 1 day ago - added=timezone.now() - relativedelta(months=1, days=1), + # More than 1 month ago, in the search timezone + added=timezone.localtime() - relativedelta(months=1, days=7), ) d3 = Document.objects.create( title="bank statement 3", @@ -706,6 +706,10 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase): @override_settings( TIME_ZONE="America/Denver", ) + @time_machine.travel( + datetime.datetime(2026, 12, 1, 0, 1, tzinfo=datetime.UTC), + tick=False, + ) def test_search_added_in_last_month_timezone_behind(self) -> None: """ GIVEN: @@ -729,8 +733,8 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase): content="things i paid for in august", pk=2, checksum="B", - # 1 month, 1 day ago - added=timezone.now() - relativedelta(months=1, days=1), + # More than 1 month ago, in the search timezone + added=timezone.localtime() - relativedelta(months=1, days=7), ) d3 = Document.objects.create( title="bank statement 3",