hass.tibber_prices/tests
anthropic-code-agent[bot] 691e917c0a
fix(services): ceil search_start to next quarter when include_current_interval=false
When include_current_interval=False, the search_start was set to the raw
now timestamp (e.g. 14:47:00.167996). The interval pool index iterates in
15-minute steps from that exact value, so keys like 14:47:00, 15:02:00, …
never matched any cached interval (which are always on :00/:15/:30/:45
boundaries), causing no data to be found and returning no_data_in_range.

Fix: replace `now` with `ceil_to_next_quarter_hour(now)` which is always
`floor(now) + 15min`. This skips the interval that is currently in progress
(14:30–14:45 interval) and starts at the first interval that hasn't begun
yet (15:00), consistent with the intent of include_current_interval=False.

Fixes #190

User-Impact: find_cheapest_block/find_most_expensive_block/find_cheapest_hours
with include_current_interval=false and search_scope=next_24h (or no scope)
no longer returns no_data_in_range when data is available.

Agent-Logs-Url: https://github.com/jpawlowski/hass.tibber_prices/sessions/0ea804f9-7c98-4e5a-b40f-469954fa9daa

Co-authored-by: jpawlowski <75446+jpawlowski@users.noreply.github.com>
2026-07-27 16:14:20 +00:00
..
services fix(services): ceil search_start to next quarter when include_current_interval=false 2026-07-27 16:14:20 +00:00
__init__.py test: add pytest framework and midnight-crossing tests 2025-11-21 23:47:01 +00:00
test_avg_none_fallback.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_best_price_e2e.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_binary_sensor_period_attributes.py fix(periods): stabilize best and peak period outputs 2026-04-25 22:46:38 +00:00
test_config_validators.py refactor(config): use negative values for Best Price min_distance 2025-11-22 04:44:57 +00:00
test_coordinator_shutdown.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_interval_pool_memory_leak.py fix(interval_pool): rebuild index after dead interval cleanup without empty groups 2026-04-17 12:00:37 +00:00
test_interval_pool_optimization.py chore(testing): add optional Pyright checks for tests 2026-04-25 22:46:43 +00:00
test_level_filtering.py fix(periods): keep negative best-price windows strictly local 2026-04-25 20:00:04 +00:00
test_lifecycle_state.py fix(sensors): ensure connection/tomorrow_data/lifecycle consistency 2025-11-22 04:45:57 +00:00
test_mean_median_display.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_midnight_handler.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_midnight_periods.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_midnight_turnover.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_minmax_none_fallback.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_negative_best_price_periods.py fix(periods): keep negative best-price windows strictly local 2026-04-25 20:00:04 +00:00
test_next_api_poll.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_peak_price_e2e.py refactor(periods): enhance peak period filtering and validation logic 2026-04-17 22:24:18 +00:00
test_percentage_calculations.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_period_calculation.py test(period): document period calculation testing strategy 2025-11-22 04:47:09 +00:00
test_period_overlap.py fix(periods): stabilize best and peak period outputs 2026-04-25 22:46:38 +00:00
test_period_statistics.py fix(periods): stabilize best and peak period outputs 2026-04-25 22:46:38 +00:00
test_periods_hash.py fix(periods): stabilize best and peak period outputs 2026-04-25 22:46:38 +00:00
test_price_calculations.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_price_window.py feat(services): add power-profile-weighted window selection 2026-05-03 22:16:08 +00:00
test_rating_threshold_validation.py chore(testing): add optional Pyright checks for tests 2026-04-25 22:46:43 +00:00
test_relaxation.py fix(periods): separate smoothed levels from period detection 2026-05-03 19:40:34 +00:00
test_resource_cleanup.py chore(testing): add optional Pyright checks for tests 2026-04-25 22:46:43 +00:00
test_sensor_consistency.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_sensor_timer_assignment.py refactor(repairs): simplify currency mode change notification to one-shot 2026-04-15 10:00:59 +00:00
test_time_service.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_timer_scheduling.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00
test_tomorrow_data_refresh.py fix(periods): separate smoothed levels from period detection 2026-05-03 19:40:34 +00:00
test_user_data_validation.py fix(services): use injected now in resolve_search_range day offset 2026-04-14 19:33:24 +00:00