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

Running tests in different timezone #56

Open
jyaw opened this issue Aug 26, 2022 · 3 comments
Open

Running tests in different timezone #56

jyaw opened this issue Aug 26, 2022 · 3 comments

Comments

@jyaw
Copy link
Contributor

jyaw commented Aug 26, 2022

I was troubleshooting some issues with the CGM features and wanted to run the tests...

It seems that's not possible outside of the assertequal-assumed timezone of America/New_York (-04:00). The called functions automatically use the .env-specified TIMEZONE_NAME, while the tests use a specific timezone.

It seems like we could...

  1. Adjust the timezone-related application functions to take timezone as an input so we could specifically call them with the America/New_York time zone...
  2. We could adjust the test functions to use the user-specified timezone.
  3. Other options?

After thinking about this a second.... I think I'd opt for modifying the tests "time" fields to read something like...

arrow.get("2021-10-12 00:00:30-04:00").replace(tzinfo=TIMEZONE_NAME).format()

It notes the original test case you had, but makes it clear you're acknowledging the user's timezone should be used since the application functions use it. Any thoughts before I do some search/replace? There's alot of tests involving the timezone in here and I didnt want to do this if there's a better way to approach it...

@jyaw
Copy link
Contributor Author

jyaw commented Aug 26, 2022

Note that an easy workaround for me to get tests working was to just make sure I had the .env set to America/New_York. Could also just comment it out I guess...

@jwoglom
Copy link
Owner

jwoglom commented Aug 26, 2022

It would probably make sense and be best if the tests ran across multiple timezones in order to catch deficiencies (e.g., the bug with the timezone-formatting log).

I think your suggestion for using the specified timezone with arrow makes sense. The tests all being hard-coded to America/New_York wasn't so much intentional as it was convenient since I live in that timezone, and all of my data to test against in t:connect and Nightscout are also in that tz.

I'd suggest making a single test file or section of test files tz-aware first in a PR before starting a massive refactor, just to make sure this approach will work ok.

@jyaw
Copy link
Contributor Author

jyaw commented Aug 27, 2022

That works, can try to commit a test file this weekend

jyaw added a commit to jyaw/tconnectsync that referenced this issue Aug 29, 2022
…faults to using the TIMEZONE_NAME tz in the users .env file, defaults to 'America/New_York' if no .env file. Updated the applicable date strings with -04:00 in test_therapy_event.py and it seems to work for me, test come back ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants