Use non-autospec mock for Reolink service tests (#147440)

This commit is contained in:
Abílio Costa 2025-06-24 17:37:05 +01:00 committed by GitHub
parent 54e5107c34
commit 0f112bb9c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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."""