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

Initial attempt at handling user tz in tests #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
25 changes: 13 additions & 12 deletions tests/domain/test_therapy_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from tconnectsync.domain.bolus import Bolus

from tconnectsync.domain.therapy_event import BolusTherapyEvent, CGMTherapyEvent
from ..util.utilities import replace_with_user_tz

class TestCGMTherapyEvent(unittest.TestCase):
maxDiff = None
Expand Down Expand Up @@ -103,8 +104,8 @@ def test_standard_to_bolus(self):
description="Standard",
complete="1",
completion="Completed",
request_time="2022-07-21 12:27:36-04:00",
completion_time="2022-07-21 12:29:21-04:00",
request_time=replace_with_user_tz("2022-07-21 12:27:36-04:00"),
completion_time=replace_with_user_tz("2022-07-21 12:29:21-04:00"),
insulin="4.17",
requested_insulin="4.17",
carbs="25",
Expand Down Expand Up @@ -176,8 +177,8 @@ def test_correction_to_bolus(self):
description="Automatic Bolus/Correction",
complete="1",
completion="Completed",
request_time="2022-07-21 11:53:08-04:00",
completion_time="2022-07-21 11:55:24-04:00",
request_time=replace_with_user_tz("2022-07-21 11:53:08-04:00"),
completion_time=replace_with_user_tz("2022-07-21 11:55:24-04:00"),
insulin="2.9",
requested_insulin="2.9",
carbs="0",
Expand Down Expand Up @@ -259,16 +260,16 @@ def test_extended_bolus_incomplete_to_bolus(self):
description="Extended 50.00%/0.00",
complete="0",
completion="",
request_time="2022-08-09 23:19:15-04:00",
completion_time="2022-08-09 23:20:04-04:00",
request_time=replace_with_user_tz("2022-08-09 23:19:15-04:00"),
completion_time=replace_with_user_tz("2022-08-09 23:20:04-04:00"),
insulin="0.2",
requested_insulin="0.2",
carbs="0",
bg="131",
user_override="1",
extended_bolus="1",
bolex_completion_time="",
bolex_start_time="2022-08-09 23:20:04-04:00"
bolex_start_time=replace_with_user_tz("2022-08-09 23:20:04-04:00")
)))

extendedBolusJson = {
Expand Down Expand Up @@ -347,21 +348,21 @@ def test_extended_bolus_complete_to_bolus(self):
description="Extended 50.00%/0.00",
complete="1",
completion="Completed",
request_time="2022-08-09 23:19:15-04:00",
completion_time="2022-08-09 23:20:04-04:00",
request_time=replace_with_user_tz("2022-08-09 23:19:15-04:00"),
completion_time=replace_with_user_tz("2022-08-09 23:20:04-04:00"),
insulin="0.2",
requested_insulin="0.2",
carbs="0",
bg="131",
user_override="1",
extended_bolus="1",
bolex_completion_time="2022-08-09 23:35:03-04:00",
bolex_start_time="2022-08-09 23:20:04-04:00"
bolex_completion_time=replace_with_user_tz("2022-08-09 23:35:03-04:00"),
bolex_start_time=replace_with_user_tz("2022-08-09 23:20:04-04:00")
)))


BOLUS_FULL_EXAMPLES = [
TestBolusTherapyEvent.standardJson,
TestBolusTherapyEvent.correctionJson,
TestBolusTherapyEvent.extendedBolusJson
]
]
Empty file added tests/util/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions tests/util/utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import arrow
from tconnectsync.secret import TIMEZONE_NAME

"""
Replaces timezone in string with provided timezone string, defaults to 'America/New_York'
Example 1: replace_datetime_tz("2021-04-01 23:15:30-04:00")
Example 2: replace_datetime_tz("2021-04-01 23:15:30-04:00", 'America/Chicago')
"""
def replace_with_user_tz(date, tz=TIMEZONE_NAME):
return arrow.get(date, tzinfo=tz).format()