Re-plan the missed sweep when the panel adopts a time zone
The scheduler loaded settings once per cycle and slept on them until the old rollover, so a zone adopted from Home Assistant after start-up left a UTC host sweeping at UTC midnight (20:00 in New York), marking quests missed hours early. `MissedSweepScheduler.settings_changed` now wakes the sleeping loop when the stored zone or rollover time differs from the one it planned with; the panel's household clock calls it after adopting a reported zone. Before sweeping, the loop re-reads the settings and re-plans instead if they no longer match its plan. Tests: the scheduler re-plans for New York midnight when a panel request adopts the zone mid-sleep, and skips a stale sweep when the zone changed without a wake-up. The admin-precedence and invalid-header tests now prove adoption first, and the SSE client test asserts the timezone header rides beside the Authorization header. Task: 6351b36d-0eef-4e7d-bf5a-96b754cbc883 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -351,6 +351,24 @@ async def test_stream_events_yields_documented_frames_and_sends_bearer() -> None
|
||||
assert call["json"] is None
|
||||
|
||||
|
||||
async def test_stream_events_reports_household_timezone() -> None:
|
||||
"""The SSE GET carries Home Assistant's zone beside the Bearer token
|
||||
(task 6351b36d), like the snapshot and completion requests."""
|
||||
frame = _frame_text(*DOCUMENTED_FRAMES[0])
|
||||
transport = _StreamTransport(_StreamingResponse(200, [frame]))
|
||||
client = NestQuestApiClient(
|
||||
BASE_URL, TOKEN, transport, household_timezone="America/New_York"
|
||||
)
|
||||
|
||||
frames = [frame async for frame in client.stream_events()]
|
||||
|
||||
assert frames == [DOCUMENTED_FRAMES[0]]
|
||||
assert transport.calls[0]["headers"] == {
|
||||
"Authorization": f"Bearer {TOKEN}",
|
||||
"X-NestQuest-Timezone": "America/New_York",
|
||||
}
|
||||
|
||||
|
||||
async def test_stream_events_buffers_lines_across_chunks_and_joins_data() -> None:
|
||||
"""Chunk-split lines parse, and multi-line data joins per SSE rules."""
|
||||
first_type, first_payload = DOCUMENTED_FRAMES[0]
|
||||
|
||||
Reference in New Issue
Block a user