Tests compare against Home Assistant's date, and 1.15.1 - #18
Merged
Merged
Conversation
Three usage tests built their expected day with date.today(). The integration and the test harness use Home Assistant's clock, which pytest-homeassistant-custom-component sets to US/Pacific. Between midnight UTC and midnight in US/Pacific the two dates differ, and the tests failed. They now use dt_util.now().date(). The same 67 tests pass with TZ set to Europe/Amsterdam, UTC, America/Los_Angeles and Pacific/Kiritimati. Version 1.15.1. The integration code does not change.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three usage tests failed every day between midnight UTC and midnight in US/Pacific. This fixes the tests and releases 1.15.1. The integration code does not change.
Cause
tests/test_ai_task.pyandtests/test_init.pybuilt the expected day withdate.today(), which is the system date. The integration uses Home Assistant's clock, and the test harness sets it toUS/Pacific. When the two dates differ, the tests fail:test_what_the_task_spends_lands_in_the_day_s_usage:date(2026, 9, 22) == date(2026, 9, 23)fails.test_yesterdays_total_does_not_count_against_today:'101' == '2'fails. The stored "yesterday" was today for Home Assistant.test_a_spent_budget_skips_the_probe_and_still_says_so.The tests now use
dt_util.now().date().Gate
Run at 05:30 in Europe/Amsterdam, inside the window where main fails.
test_ai_task.py+test_init.py, TZ=Europe/Amsterdam