Skip to content

Commit a16f2d2

Browse files
committed
Changed DateTime to use zoneinfo instead of pytz
Removed a duplicate line from base_page Removed a pytest.mark that was committed by mistake
1 parent 13ca365 commit a16f2d2

File tree

3 files changed

+45
-21
lines changed

3 files changed

+45
-21
lines changed

pages/base_page.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ def bowel_cancer_screening_system_header_is_displayed(self) -> None:
8787
expect(self.bowel_cancer_screening_system_header).to_contain_text(
8888
"Bowel Cancer Screening System"
8989
)
90-
expect(self.bowel_cancer_screening_system_header).to_contain_text(
91-
"Bowel Cancer Screening System"
92-
)
9390

9491
def main_menu_header_is_displayed(self) -> None:
9592
expect(self.main_menu__header).to_contain_text("Main Menu")

tests/test_reports_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
107107
report_timestamp
108108
)
109109

110-
@pytest.mark.only
110+
111111
def test_failsafe_reports_screening_subjects_with_inactive_open_episode(
112112
page: Page,
113113
) -> None:

utils/date_time_utils.py

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from datetime import datetime, timedelta
2-
import pytz
1+
from datetime import datetime, timedelta, tzinfo
2+
from zoneinfo import ZoneInfo
33

44

55
class DateTimeUtils:
@@ -71,27 +71,54 @@ def get_a_day_of_week(date: datetime) -> str:
7171

7272
@staticmethod
7373
def report_timestamp_date_format() -> str:
74-
"""Gets the current datetime in the timestamp format used on the report pages."""
75-
# Use this option if bcss is displaying correct DST times
76-
# return DateTimeUtils.format_date(datetime.now(), "%d/%m/%Y at %H:%M:%S")
74+
# If the bcss timestamp is displaying in UTC, set this to True
75+
# If the bcss timestamp is displaying in DST, set this to False
76+
USE_UTC = True
7777

78-
# Use this option if bcss is displaying UTC times
79-
return DateTimeUtils.format_date(datetime.now(pytz.utc), "%d/%m/%Y at %H:%M:%S")
78+
"""Gets the current datetime in the timestamp format used on the report pages.
79+
Based on the value of `USE_UTC`, it chooses the appropriate timezone.
80+
"""
81+
if USE_UTC:
82+
return DateTimeUtils.format_date(
83+
datetime.now(ZoneInfo("UTC")), "%d/%m/%Y at %H:%M:%S"
84+
)
85+
else:
86+
return DateTimeUtils.format_date(
87+
datetime.now(ZoneInfo("Europe/London")), "%d/%m/%Y at %H:%M:%S"
88+
)
8089

8190
@staticmethod
8291
def fobt_kits_logged_but_not_read_report_timestamp_date_format() -> str:
83-
"""Gets the current datetime in the format used for FOBT Kits Logged but Not Read report."""
84-
# Use this option if bcss is displaying correct DST times
85-
return DateTimeUtils.format_date(datetime.now(), "%d %b %Y %H:%M:%S")
92+
# If the bcss timestamp is displaying in UTC, set this to True
93+
# If the bcss timestamp is displaying in DST, set this to False
94+
USE_UTC = False
8695

87-
# Use this option if bcss is displaying UTC times
88-
# return DateTimeUtils.format_date(datetime.now(pytz.utc), "%d %b %Y %H:%M:%S")
96+
"""Gets the current datetime in the format used for FOBT Kits Logged but Not Read report.
97+
Based on the value of `USE_UTC`, it chooses the appropriate timezone.
98+
"""
99+
if USE_UTC:
100+
return DateTimeUtils.format_date(
101+
datetime.now(ZoneInfo("UTC")), "%d %b %Y %H:%M:%S"
102+
)
103+
else:
104+
return DateTimeUtils.format_date(
105+
datetime.now(ZoneInfo("Europe/London")), "%d %b %Y %H:%M:%S"
106+
)
89107

90108
@staticmethod
91109
def screening_practitioner_appointments_report_timestamp_date_format() -> str:
92-
"""Gets the current datetime in the format used for Screening Practitioner Appointments report."""
93-
# Use this option if bcss is displaying correct DST times
94-
# return DateTimeUtils.format_date(datetime.now(), "%d.%m.%Y at %H:%M:%S")
110+
# If the bcss timestamp is displaying in UTC, set this to True
111+
# If the bcss timestamp is displaying in DST, set this to False
112+
USE_UTC = True
95113

96-
# Use this option if bcss is displaying UTC times
97-
return DateTimeUtils.format_date(datetime.now(pytz.utc), "%d.%m.%Y at %H:%M:%S")
114+
"""Gets the current datetime in the format used for Screening Practitioner Appointments report.
115+
Based on the value of `USE_UTC`, it chooses the appropriate timezone.
116+
"""
117+
if USE_UTC:
118+
return DateTimeUtils.format_date(
119+
datetime.now(ZoneInfo("UTC")), "%d.%m.%Y at %H:%M:%S"
120+
)
121+
else:
122+
return DateTimeUtils.format_date(
123+
datetime.now(ZoneInfo("Europe/London")), "%d.%m.%Y at %H:%M:%S"
124+
)

0 commit comments

Comments
 (0)