From 9df5088c57bd28aec3efc7043afb6d15144b23e9 Mon Sep 17 00:00:00 2001 From: Darren Boss Date: Mon, 6 Nov 2023 16:10:29 -0800 Subject: [PATCH] Time change test --- api/app/tests/utils/test_time.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/app/tests/utils/test_time.py b/api/app/tests/utils/test_time.py index f8881e9d9..ea9cf3751 100644 --- a/api/app/tests/utils/test_time.py +++ b/api/app/tests/utils/test_time.py @@ -1,5 +1,6 @@ from datetime import datetime from app.utils.time import get_utc_datetime, get_days_from_range +import pytz def test_get_utc_datetime(): @@ -42,3 +43,11 @@ def test_time_range_end_before_start(): oct_10_2022 = datetime(year=2022, month=10, day=10, hour=8, minute=30, second=30) days = get_days_from_range(oct_10_2022, oct_1_2022) assert (len(days) == 0) + +def test_time_range_across_time_change(): + "Time change should not impact range." + vancouver_tz = pytz.timezone("America/Vancouver") + nov_1_2023 = vancouver_tz.localize(datetime(year=2023, month=11, day=1, hour=0, minute=0, second=0)) + nov_6_2023 = vancouver_tz.localize(datetime(year=2023, month=11, day=6, hour=23, minute=59, second=59)) + days = get_days_from_range(nov_1_2023, nov_6_2023) + assert (len(days) == 6)