mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use non-autospec mock for Reolink service tests (#147440)
This commit is contained in:
parent
54e5107c34
commit
0f112bb9c4
@ -20,8 +20,8 @@ from tests.common import MockConfigEntry
|
||||
async def test_play_chime_service_entity(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
test_chime: Chime,
|
||||
reolink_host: MagicMock,
|
||||
reolink_chime: Chime,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test chime play service."""
|
||||
@ -37,14 +37,14 @@ async def test_play_chime_service_entity(
|
||||
device_id = entity.device_id
|
||||
|
||||
# Test chime play service with device
|
||||
test_chime.play = AsyncMock()
|
||||
reolink_chime.play = AsyncMock()
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"play_chime",
|
||||
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
|
||||
blocking=True,
|
||||
)
|
||||
test_chime.play.assert_called_once()
|
||||
reolink_chime.play.assert_called_once()
|
||||
|
||||
# Test errors
|
||||
with pytest.raises(ServiceValidationError):
|
||||
@ -55,7 +55,7 @@ async def test_play_chime_service_entity(
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
test_chime.play = AsyncMock(side_effect=ReolinkError("Test error"))
|
||||
reolink_chime.play = AsyncMock(side_effect=ReolinkError("Test error"))
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -64,7 +64,7 @@ async def test_play_chime_service_entity(
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
test_chime.play = AsyncMock(side_effect=InvalidParameterError("Test error"))
|
||||
reolink_chime.play = AsyncMock(side_effect=InvalidParameterError("Test error"))
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -73,7 +73,7 @@ async def test_play_chime_service_entity(
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
reolink_connect.chime.return_value = None
|
||||
reolink_host.chime.return_value = None
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -86,8 +86,8 @@ async def test_play_chime_service_entity(
|
||||
async def test_play_chime_service_unloaded(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
test_chime: Chime,
|
||||
reolink_host: MagicMock,
|
||||
reolink_chime: Chime,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test chime play service when config entry is unloaded."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user