forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated tests for home-assistant#25814
Please notes that unit tests were inadequate in the past, or 28514 would have been caught. The new tests set one of three time zones explicitly for all day event tests, and the all day event tests have been modified to patch the return value of homeassistant.util.dt.now to be in the local time zone, instead of always UTC. By having it return times in the local time zone, the tests better match real-world usage -- homeassistant.util.dt.now wouldn't return a UTC time when a different time zone is set. The unit tests now check for a single occurrence all day event at the beginning of the local day, in the middle of the local day, and at the end of the local day. Each check is run in three separate time zones, Asia/Baghdad, UTC, and America/New_York. The times are chose such that the early in the local day time for Asia/Baghdad is actually the day before in UTC, and the late in the local day time for America/New_York is actually the next day in UTC. This guarantees that when the tests pass, there are no internal checks that shifted what should be a local time as if it were UTC being shifted to local time, which was bug home-assistant#25814. Similar changes were made for the recurring all day event test, too. Note that if you run the new unit tests without the fixed code in this patch, that the following tests will fail: test_all_day_event_returned_early[pyloop-baghdad] test_all_day_event_returned_late[pyloop-new_york] test_event_rrule_all_day_late[pyloop-new_york] After applying the fix, all tests will succeed. If you're wondering why test_event_rrule_all_day_early[pyloop-baghdad] doesn't fail without the fix, it's because we're not checking on the first occurrence of the event. If we did that, the test would fail just like test_all_day_event_returned_early[pyloop-baghdad]. However, since by checking the first occurrence we're running the same condition that test_all_day_event_returned_early[pyloop-baghdad] already checks, it would be redundant to add a test which fails for a recurring event in that time zone. The whole point of the test_event_rrule_all_day tests is to ensure that recurrences are returned when it's not the first occurrence.
- Loading branch information
Showing
1 changed file
with
153 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters