Reolink add 100% coverage of number platform (#124465)

* Add 100% number test coverage

* review comments

* fix styling

* re-add AsyncMock for chime
This commit is contained in:
starkillerOG
2024-08-23 12:34:58 +02:00
committed by GitHub
parent 4e94ce0cc7
commit ab064a7f36
6 changed files with 121 additions and 20 deletions

View File

@@ -41,7 +41,6 @@ async def test_floodlight_mode_select(
entity_id = f"{Platform.SELECT}.{TEST_NVR_NAME}_floodlight_mode"
assert hass.states.get(entity_id).state == "auto"
reolink_connect.set_whiteled = AsyncMock()
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
@@ -50,7 +49,7 @@ async def test_floodlight_mode_select(
)
reolink_connect.set_whiteled.assert_called_once()
reolink_connect.set_whiteled = AsyncMock(side_effect=ReolinkError("Test error"))
reolink_connect.set_whiteled.side_effect = ReolinkError("Test error")
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
SELECT_DOMAIN,
@@ -59,9 +58,7 @@ async def test_floodlight_mode_select(
blocking=True,
)
reolink_connect.set_whiteled = AsyncMock(
side_effect=InvalidParameterError("Test error")
)
reolink_connect.set_whiteled.side_effect = InvalidParameterError("Test error")
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
SELECT_DOMAIN,
@@ -94,7 +91,6 @@ async def test_play_quick_reply_message(
entity_id = f"{Platform.SELECT}.{TEST_NVR_NAME}_play_quick_reply_message"
assert hass.states.get(entity_id).state == STATE_UNKNOWN
reolink_connect.play_quick_reply = AsyncMock()
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
@@ -131,7 +127,7 @@ async def test_chime_select(
)
test_chime.set_tone.assert_called_once()
test_chime.set_tone = AsyncMock(side_effect=ReolinkError("Test error"))
test_chime.set_tone.side_effect = ReolinkError("Test error")
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
SELECT_DOMAIN,
@@ -140,7 +136,7 @@ async def test_chime_select(
blocking=True,
)
test_chime.set_tone = AsyncMock(side_effect=InvalidParameterError("Test error"))
test_chime.set_tone.side_effect = InvalidParameterError("Test error")
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
SELECT_DOMAIN,