Add missing method mock to Reolink chime test (#147447)

This commit is contained in:
Abílio Costa 2025-06-24 19:06:54 +01:00 committed by GitHub
parent 3148719864
commit e8a534be9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -274,6 +274,7 @@ def reolink_chime(reolink_host: MagicMock) -> None:
"people": {"switch": 0, "musicId": 1},
"visitor": {"switch": 1, "musicId": 2},
}
TEST_CHIME.remove = AsyncMock()
reolink_host.chime_list = [TEST_CHIME]
reolink_host.chime.return_value = TEST_CHIME

View File

@ -7,7 +7,6 @@ from unittest.mock import AsyncMock, MagicMock, Mock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from reolink_aio.api import Chime
from reolink_aio.exceptions import (
CredentialsInvalidError,
LoginPrivacyModeError,
@ -270,22 +269,25 @@ async def test_removing_disconnected_cams(
@pytest.mark.parametrize(
("attr", "value", "expected_models"),
("attr", "value", "expected_models", "expected_remove_call_count"),
[
(
None,
None,
[TEST_HOST_MODEL, TEST_CAM_MODEL, CHIME_MODEL],
1,
),
(
"connect_state",
-1,
[TEST_HOST_MODEL, TEST_CAM_MODEL],
0,
),
(
"remove",
-1,
[TEST_HOST_MODEL, TEST_CAM_MODEL],
1,
),
],
)
@ -294,12 +296,13 @@ async def test_removing_chime(
hass_ws_client: WebSocketGenerator,
config_entry: MockConfigEntry,
reolink_host: MagicMock,
reolink_chime: Chime,
reolink_chime: MagicMock,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
attr: str | None,
value: Any,
expected_models: list[str],
expected_remove_call_count: int,
) -> None:
"""Test removing a chime."""
reolink_host.channels = [0]
@ -324,7 +327,7 @@ async def test_removing_chime(
"""Remove chime."""
reolink_chime.connect_state = -1
reolink_chime.remove = test_remove_chime
reolink_chime.remove = AsyncMock(side_effect=test_remove_chime)
elif attr is not None:
setattr(reolink_chime, attr, value)
@ -334,6 +337,7 @@ async def test_removing_chime(
if device.model == CHIME_MODEL:
response = await client.remove_device(device.id, config_entry.entry_id)
assert response["success"] == expected_success
assert reolink_chime.remove.call_count == expected_remove_call_count
device_entries = dr.async_entries_for_config_entry(
device_registry, config_entry.entry_id