|
|
@@ -754,6 +754,25 @@ async def test_reconcile_promotes_next_when_check_in_elapsed(coordinator: RoomCa
|
|
|
assert coordinator.store.get(STORE_CURRENT).guest_name == "Active Guest"
|
|
|
|
|
|
|
|
|
+async def test_reconcile_turns_off_guest_mode_when_store_already_cleared(coordinator: RoomCalCoordinator):
|
|
|
+ """Store was cleared (e.g. checkout write ran) but guest-mode-off action never ran."""
|
|
|
+ # No current reservation in store — it was already cleared before HA was disabled.
|
|
|
+ mock_switch = MagicMock()
|
|
|
+ mock_switch.async_turn_on = AsyncMock()
|
|
|
+ mock_switch.async_turn_off = AsyncMock()
|
|
|
+ coordinator._room_state_switch = mock_switch
|
|
|
+
|
|
|
+ with (
|
|
|
+ patch.object(coordinator, "_is_mode_sync_on", return_value=True),
|
|
|
+ patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_RECONCILE_NOW),
|
|
|
+ ):
|
|
|
+ await coordinator.async_reconcile_from_store()
|
|
|
+ coordinator.cancel_mode_sync()
|
|
|
+
|
|
|
+ mock_switch.async_turn_off.assert_awaited_once()
|
|
|
+ mock_switch.async_turn_on.assert_not_awaited()
|
|
|
+
|
|
|
+
|
|
|
async def test_reconcile_does_not_touch_guest_mode_when_mode_sync_off(coordinator: RoomCalCoordinator):
|
|
|
await coordinator.store.async_set(STORE_CURRENT, _ACTIVE)
|
|
|
mock_switch = MagicMock()
|