jwoglom / tconnectsync

Syncs insulin pump data from Tandem t:connect to Nightscout for the t:slim X2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running tests in different timezone

jyaw opened this issue · comments

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...

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...

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.

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