mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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(
|
async def test_play_chime_service_entity(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
reolink_connect: MagicMock,
|
reolink_host: MagicMock,
|
||||||
test_chime: Chime,
|
reolink_chime: Chime,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test chime play service."""
|
"""Test chime play service."""
|
||||||
@ -37,14 +37,14 @@ async def test_play_chime_service_entity(
|
|||||||
device_id = entity.device_id
|
device_id = entity.device_id
|
||||||
|
|
||||||
# Test chime play service with device
|
# Test chime play service with device
|
||||||
test_chime.play = AsyncMock()
|
reolink_chime.play = AsyncMock()
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
"play_chime",
|
"play_chime",
|
||||||
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
|
{ATTR_DEVICE_ID: [device_id], ATTR_RINGTONE: "attraction"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
test_chime.play.assert_called_once()
|
reolink_chime.play.assert_called_once()
|
||||||
|
|
||||||
# Test errors
|
# Test errors
|
||||||
with pytest.raises(ServiceValidationError):
|
with pytest.raises(ServiceValidationError):
|
||||||
@ -55,7 +55,7 @@ async def test_play_chime_service_entity(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
test_chime.play = AsyncMock(side_effect=ReolinkError("Test error"))
|
reolink_chime.play = AsyncMock(side_effect=ReolinkError("Test error"))
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -64,7 +64,7 @@ async def test_play_chime_service_entity(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
test_chime.play = AsyncMock(side_effect=InvalidParameterError("Test error"))
|
reolink_chime.play = AsyncMock(side_effect=InvalidParameterError("Test error"))
|
||||||
with pytest.raises(ServiceValidationError):
|
with pytest.raises(ServiceValidationError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -73,7 +73,7 @@ async def test_play_chime_service_entity(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
reolink_connect.chime.return_value = None
|
reolink_host.chime.return_value = None
|
||||||
with pytest.raises(ServiceValidationError):
|
with pytest.raises(ServiceValidationError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -86,8 +86,8 @@ async def test_play_chime_service_entity(
|
|||||||
async def test_play_chime_service_unloaded(
|
async def test_play_chime_service_unloaded(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
reolink_connect: MagicMock,
|
reolink_host: MagicMock,
|
||||||
test_chime: Chime,
|
reolink_chime: Chime,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test chime play service when config entry is unloaded."""
|
"""Test chime play service when config entry is unloaded."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user