|
@@ -912,13 +912,13 @@ async def test_check_in_sets_lock_codes(hass: HomeAssistant, coordinator_with_lo
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_in()
|
|
await coordinator_with_locks._async_do_check_in()
|
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
|
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.front_door", "slot": 5, "code": "7890"}, blocking=True)
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front_door", "slot": 5, "enabled": True}, blocking=True)
|
|
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.front_door", "slot": 5, "code": "7890"})
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front_door", "slot": 5, "enabled": True})
|
|
|
mock_switch.async_turn_on.assert_awaited_once()
|
|
mock_switch.async_turn_on.assert_awaited_once()
|
|
|
|
|
|
|
|
|
|
|
|
@@ -936,15 +936,15 @@ async def test_check_in_sets_codes_on_all_locks(hass: HomeAssistant):
|
|
|
patch.object(coord, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coord, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coord, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coord, "_is_use_zwave_on", return_value=True),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coord, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coord._async_do_check_in()
|
|
await coord._async_do_check_in()
|
|
|
coord.cancel_mode_sync()
|
|
coord.cancel_mode_sync()
|
|
|
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.front", "slot": 5, "code": "7890"}, blocking=True)
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.back", "slot": 5, "code": "7890"}, blocking=True)
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front", "slot": 5, "enabled": True}, blocking=True)
|
|
|
|
|
- mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.back", "slot": 5, "enabled": True}, blocking=True)
|
|
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.front", "slot": 5, "code": "7890"})
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_code", {"lock_entity_id": "lock.back", "slot": 5, "code": "7890"})
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front", "slot": 5, "enabled": True})
|
|
|
|
|
+ mock_call.assert_any_await("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.back", "slot": 5, "enabled": True})
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_check_in_skips_lock_codes_when_door_code_none(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
async def test_check_in_skips_lock_codes_when_door_code_none(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
@@ -963,7 +963,7 @@ async def test_check_in_skips_lock_codes_when_door_code_none(hass: HomeAssistant
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_in()
|
|
await coordinator_with_locks._async_do_check_in()
|
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
@@ -981,14 +981,12 @@ async def test_check_in_skips_lock_codes_when_use_zwave_off(hass: HomeAssistant,
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=False),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=False),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_in()
|
|
await coordinator_with_locks._async_do_check_in()
|
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
|
|
|
|
|
|
- assert not any(
|
|
|
|
|
- c.args[:1] == ("zlock_slots",) for c in mock_call.await_args_list
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ mock_call.assert_not_awaited()
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_check_in_skips_lock_codes_when_no_locks_configured(hass: HomeAssistant, coordinator: RoomCalCoordinator):
|
|
async def test_check_in_skips_lock_codes_when_no_locks_configured(hass: HomeAssistant, coordinator: RoomCalCoordinator):
|
|
@@ -1000,14 +998,12 @@ async def test_check_in_skips_lock_codes_when_no_locks_configured(hass: HomeAssi
|
|
|
patch.object(coordinator, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator, "_is_use_zwave_on", return_value=True),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator._async_do_check_in()
|
|
await coordinator._async_do_check_in()
|
|
|
coordinator.cancel_mode_sync()
|
|
coordinator.cancel_mode_sync()
|
|
|
|
|
|
|
|
- assert not any(
|
|
|
|
|
- c.args[:1] == ("zlock_slots",) for c in mock_call.await_args_list
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ mock_call.assert_not_awaited()
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_check_in_lock_error_still_activates_guest_mode(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
async def test_check_in_lock_error_still_activates_guest_mode(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
@@ -1020,7 +1016,7 @@ async def test_check_in_lock_error_still_activates_guest_mode(hass: HomeAssistan
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
patch("custom_components.room_cal_ha.coordinator.dt_util.now", return_value=_AT_CHECK_IN),
|
|
|
- patch.object(hass.services, "async_call", side_effect=HomeAssistantError("lock offline")),
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", side_effect=HomeAssistantError("lock offline")),
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_in()
|
|
await coordinator_with_locks._async_do_check_in()
|
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
coordinator_with_locks.cancel_mode_sync()
|
|
@@ -1041,11 +1037,11 @@ async def test_check_out_disables_lock_slot(hass: HomeAssistant, coordinator_wit
|
|
|
with (
|
|
with (
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_out()
|
|
await coordinator_with_locks._async_do_check_out()
|
|
|
|
|
|
|
|
- mock_call.assert_awaited_once_with("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front_door", "slot": 5, "enabled": False}, blocking=True)
|
|
|
|
|
|
|
+ mock_call.assert_awaited_once_with("zlock_slots", "set_slot_enabled", {"lock_entity_id": "lock.front_door", "slot": 5, "enabled": False})
|
|
|
mock_switch.async_turn_off.assert_awaited_once()
|
|
mock_switch.async_turn_off.assert_awaited_once()
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1056,13 +1052,11 @@ async def test_check_out_skips_lock_slot_when_use_zwave_off(hass: HomeAssistant,
|
|
|
with (
|
|
with (
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=False),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=False),
|
|
|
- patch.object(hass.services, "async_call", new_callable=AsyncMock) as mock_call,
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", new_callable=AsyncMock) as mock_call,
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_out()
|
|
await coordinator_with_locks._async_do_check_out()
|
|
|
|
|
|
|
|
- assert not any(
|
|
|
|
|
- c.args[:1] == ("zlock_slots",) for c in mock_call.await_args_list
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ mock_call.assert_not_awaited()
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_check_out_lock_error_still_deactivates_guest_mode(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
async def test_check_out_lock_error_still_deactivates_guest_mode(hass: HomeAssistant, coordinator_with_locks: RoomCalCoordinator):
|
|
@@ -1074,7 +1068,7 @@ async def test_check_out_lock_error_still_deactivates_guest_mode(hass: HomeAssis
|
|
|
with (
|
|
with (
|
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_mode_sync_on", return_value=True),
|
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
patch.object(coordinator_with_locks, "_is_use_zwave_on", return_value=True),
|
|
|
- patch.object(hass.services, "async_call", side_effect=HomeAssistantError("lock offline")),
|
|
|
|
|
|
|
+ patch.object(coordinator_with_locks, "_async_call_service", side_effect=HomeAssistantError("lock offline")),
|
|
|
):
|
|
):
|
|
|
await coordinator_with_locks._async_do_check_out()
|
|
await coordinator_with_locks._async_do_check_out()
|
|
|
|
|
|