Skip to content

Commit 1b7e53f

Browse files
MartinHjelmarefrenck
authored andcommittedMar 21, 2025··
Improve Home Connect appliances test fixture (#139787)
Improve Home Connect appliances fixture
1 parent bfabf97 commit 1b7e53f

File tree

4 files changed

+267
-225
lines changed

4 files changed

+267
-225
lines changed
 

‎tests/components/home_connect/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
from typing import Any
44

5-
from aiohomeconnect.model import ArrayOfHomeAppliances, ArrayOfStatus
5+
from aiohomeconnect.model import ArrayOfStatus
66

77
from tests.common import load_json_object_fixture
88

9-
MOCK_APPLIANCES = ArrayOfHomeAppliances.from_dict(
10-
load_json_object_fixture("home_connect/appliances.json")["data"] # type: ignore[arg-type]
11-
)
129
MOCK_PROGRAMS: dict[str, Any] = load_json_object_fixture("home_connect/programs.json")
1310
MOCK_SETTINGS: dict[str, Any] = load_json_object_fixture("home_connect/settings.json")
1411
MOCK_STATUS = ArrayOfStatus.from_dict(

‎tests/components/home_connect/conftest.py

+124-87
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from aiohomeconnect.model import (
1212
ArrayOfCommands,
1313
ArrayOfEvents,
14+
ArrayOfHomeAppliances,
1415
ArrayOfOptions,
1516
ArrayOfPrograms,
1617
ArrayOfSettings,
@@ -39,15 +40,9 @@
3940
from homeassistant.core import HomeAssistant
4041
from homeassistant.setup import async_setup_component
4142

42-
from . import (
43-
MOCK_APPLIANCES,
44-
MOCK_AVAILABLE_COMMANDS,
45-
MOCK_PROGRAMS,
46-
MOCK_SETTINGS,
47-
MOCK_STATUS,
48-
)
43+
from . import MOCK_AVAILABLE_COMMANDS, MOCK_PROGRAMS, MOCK_SETTINGS, MOCK_STATUS
4944

50-
from tests.common import MockConfigEntry
45+
from tests.common import MockConfigEntry, load_fixture
5146

5247
CLIENT_ID = "1234"
5348
CLIENT_SECRET = "5678"
@@ -148,14 +143,6 @@ async def run(client: MagicMock) -> bool:
148143
return run
149144

150145

151-
def _get_specific_appliance_side_effect(ha_id: str) -> HomeAppliance:
152-
"""Get specific appliance side effect."""
153-
for appliance in copy.deepcopy(MOCK_APPLIANCES).homeappliances:
154-
if appliance.ha_id == ha_id:
155-
return appliance
156-
raise HomeConnectApiError("error.key", "error description")
157-
158-
159146
def _get_set_program_side_effect(
160147
event_queue: asyncio.Queue[list[EventMessage]], event_key: EventKey
161148
):
@@ -271,68 +258,12 @@ async def set_program_options_side_effect(ha_id: str, *_, **kwargs) -> None:
271258
return set_program_options_side_effect
272259

273260

274-
async def _get_all_programs_side_effect(ha_id: str) -> ArrayOfPrograms:
275-
"""Get all programs."""
276-
appliance_type = next(
277-
appliance
278-
for appliance in MOCK_APPLIANCES.homeappliances
279-
if appliance.ha_id == ha_id
280-
).type
281-
if appliance_type not in MOCK_PROGRAMS:
282-
raise HomeConnectApiError("error.key", "error description")
283-
284-
return ArrayOfPrograms(
285-
[
286-
EnumerateProgram.from_dict(program)
287-
for program in MOCK_PROGRAMS[appliance_type]["data"]["programs"]
288-
],
289-
Program.from_dict(MOCK_PROGRAMS[appliance_type]["data"]["programs"][0]),
290-
Program.from_dict(MOCK_PROGRAMS[appliance_type]["data"]["programs"][0]),
291-
)
292-
293-
294-
async def _get_settings_side_effect(ha_id: str) -> ArrayOfSettings:
295-
"""Get settings."""
296-
return ArrayOfSettings.from_dict(
297-
MOCK_SETTINGS.get(
298-
next(
299-
appliance
300-
for appliance in MOCK_APPLIANCES.homeappliances
301-
if appliance.ha_id == ha_id
302-
).type,
303-
{},
304-
).get("data", {"settings": []})
305-
)
306-
307-
308-
async def _get_setting_side_effect(ha_id: str, setting_key: SettingKey):
309-
"""Get setting."""
310-
for appliance in MOCK_APPLIANCES.homeappliances:
311-
if appliance.ha_id == ha_id:
312-
settings = MOCK_SETTINGS.get(
313-
next(
314-
appliance
315-
for appliance in MOCK_APPLIANCES.homeappliances
316-
if appliance.ha_id == ha_id
317-
).type,
318-
{},
319-
).get("data", {"settings": []})
320-
for setting_dict in cast(list[dict], settings["settings"]):
321-
if setting_dict["key"] == setting_key:
322-
return GetSetting.from_dict(setting_dict)
323-
raise HomeConnectApiError("error.key", "error description")
324-
325-
326-
async def _get_available_commands_side_effect(ha_id: str) -> ArrayOfCommands:
327-
"""Get available commands."""
328-
for appliance in MOCK_APPLIANCES.homeappliances:
329-
if appliance.ha_id == ha_id and appliance.type in MOCK_AVAILABLE_COMMANDS:
330-
return ArrayOfCommands.from_dict(MOCK_AVAILABLE_COMMANDS[appliance.type])
331-
raise HomeConnectApiError("error.key", "error description")
332-
333-
334261
@pytest.fixture(name="client")
335-
def mock_client(request: pytest.FixtureRequest) -> MagicMock:
262+
def mock_client(
263+
appliances: list[HomeAppliance],
264+
appliance: HomeAppliance | None,
265+
request: pytest.FixtureRequest,
266+
) -> MagicMock:
336267
"""Fixture to mock Client from HomeConnect."""
337268

338269
mock = MagicMock(
@@ -369,17 +300,78 @@ async def set_program_option_side_effect(ha_id: str, *_, **kwargs) -> None:
369300
]
370301
)
371302

303+
appliances = [appliance] if appliance else appliances
304+
372305
async def stream_all_events() -> AsyncGenerator[EventMessage]:
373306
"""Mock stream_all_events."""
374307
while True:
375308
for event in await event_queue.get():
376309
yield event
377310

378-
mock.get_home_appliances = AsyncMock(return_value=copy.deepcopy(MOCK_APPLIANCES))
311+
mock.get_home_appliances = AsyncMock(return_value=ArrayOfHomeAppliances(appliances))
312+
313+
def _get_specific_appliance_side_effect(ha_id: str) -> HomeAppliance:
314+
"""Get specific appliance side effect."""
315+
for appliance_ in appliances:
316+
if appliance_.ha_id == ha_id:
317+
return appliance_
318+
raise HomeConnectApiError("error.key", "error description")
319+
379320
mock.get_specific_appliance = AsyncMock(
380321
side_effect=_get_specific_appliance_side_effect
381322
)
382323
mock.stream_all_events = stream_all_events
324+
325+
async def _get_all_programs_side_effect(ha_id: str) -> ArrayOfPrograms:
326+
"""Get all programs."""
327+
appliance_type = next(
328+
appliance for appliance in appliances if appliance.ha_id == ha_id
329+
).type
330+
if appliance_type not in MOCK_PROGRAMS:
331+
raise HomeConnectApiError("error.key", "error description")
332+
333+
return ArrayOfPrograms(
334+
[
335+
EnumerateProgram.from_dict(program)
336+
for program in MOCK_PROGRAMS[appliance_type]["data"]["programs"]
337+
],
338+
Program.from_dict(MOCK_PROGRAMS[appliance_type]["data"]["programs"][0]),
339+
Program.from_dict(MOCK_PROGRAMS[appliance_type]["data"]["programs"][0]),
340+
)
341+
342+
async def _get_settings_side_effect(ha_id: str) -> ArrayOfSettings:
343+
"""Get settings."""
344+
return ArrayOfSettings.from_dict(
345+
MOCK_SETTINGS.get(
346+
next(
347+
appliance for appliance in appliances if appliance.ha_id == ha_id
348+
).type,
349+
{},
350+
).get("data", {"settings": []})
351+
)
352+
353+
async def _get_setting_side_effect(ha_id: str, setting_key: SettingKey):
354+
"""Get setting."""
355+
for appliance_ in appliances:
356+
if appliance_.ha_id == ha_id:
357+
settings = MOCK_SETTINGS.get(
358+
appliance_.type,
359+
{},
360+
).get("data", {"settings": []})
361+
for setting_dict in cast(list[dict], settings["settings"]):
362+
if setting_dict["key"] == setting_key:
363+
return GetSetting.from_dict(setting_dict)
364+
raise HomeConnectApiError("error.key", "error description")
365+
366+
async def _get_available_commands_side_effect(ha_id: str) -> ArrayOfCommands:
367+
"""Get available commands."""
368+
for appliance_ in appliances:
369+
if appliance_.ha_id == ha_id and appliance_.type in MOCK_AVAILABLE_COMMANDS:
370+
return ArrayOfCommands.from_dict(
371+
MOCK_AVAILABLE_COMMANDS[appliance_.type]
372+
)
373+
raise HomeConnectApiError("error.key", "error description")
374+
383375
mock.start_program = AsyncMock(
384376
side_effect=_get_set_program_side_effect(
385377
event_queue, EventKey.BSH_COMMON_ROOT_ACTIVE_PROGRAM
@@ -431,7 +423,11 @@ async def stream_all_events() -> AsyncGenerator[EventMessage]:
431423

432424

433425
@pytest.fixture(name="client_with_exception")
434-
def mock_client_with_exception(request: pytest.FixtureRequest) -> MagicMock:
426+
def mock_client_with_exception(
427+
appliances: list[HomeAppliance],
428+
appliance: HomeAppliance | None,
429+
request: pytest.FixtureRequest,
430+
) -> MagicMock:
435431
"""Fixture to mock Client from HomeConnect that raise exceptions."""
436432
mock = MagicMock(
437433
autospec=HomeConnectClient,
@@ -449,7 +445,8 @@ async def stream_all_events() -> AsyncGenerator[EventMessage]:
449445
for event in await event_queue.get():
450446
yield event
451447

452-
mock.get_home_appliances = AsyncMock(return_value=copy.deepcopy(MOCK_APPLIANCES))
448+
appliances = [appliance] if appliance else appliances
449+
mock.get_home_appliances = AsyncMock(return_value=ArrayOfHomeAppliances(appliances))
453450
mock.stream_all_events = stream_all_events
454451

455452
mock.start_program = AsyncMock(side_effect=exception)
@@ -477,12 +474,52 @@ async def stream_all_events() -> AsyncGenerator[EventMessage]:
477474

478475

479476
@pytest.fixture(name="appliance_ha_id")
480-
def mock_appliance_ha_id(request: pytest.FixtureRequest) -> str:
481-
"""Fixture to mock Appliance."""
482-
app = "Washer"
477+
def mock_appliance_ha_id(
478+
appliances: list[HomeAppliance], request: pytest.FixtureRequest
479+
) -> str:
480+
"""Fixture to get the ha_id of an appliance."""
481+
appliance_type = "Washer"
483482
if hasattr(request, "param") and request.param:
484-
app = request.param
485-
for appliance in MOCK_APPLIANCES.homeappliances:
486-
if appliance.type == app:
483+
appliance_type = request.param
484+
for appliance in appliances:
485+
if appliance.type == appliance_type:
487486
return appliance.ha_id
488-
raise ValueError(f"Appliance {app} not found")
487+
raise ValueError(f"Appliance {appliance_type} not found")
488+
489+
490+
@pytest.fixture(name="appliances")
491+
def mock_appliances(
492+
appliances_data: str, request: pytest.FixtureRequest
493+
) -> list[HomeAppliance]:
494+
"""Fixture to mock the returned appliances."""
495+
appliances = ArrayOfHomeAppliances.from_json(appliances_data).homeappliances
496+
appliance_types = {appliance.type for appliance in appliances}
497+
if hasattr(request, "param") and request.param:
498+
appliance_types = request.param
499+
return [appliance for appliance in appliances if appliance.type in appliance_types]
500+
501+
502+
@pytest.fixture(name="appliance")
503+
def mock_appliance(
504+
appliances_data: str, request: pytest.FixtureRequest
505+
) -> HomeAppliance | None:
506+
"""Fixture to mock a single specific appliance to return."""
507+
appliance_type = None
508+
if hasattr(request, "param") and request.param:
509+
appliance_type = request.param
510+
return next(
511+
(
512+
appliance
513+
for appliance in ArrayOfHomeAppliances.from_json(
514+
appliances_data
515+
).homeappliances
516+
if appliance.type == appliance_type
517+
),
518+
None,
519+
)
520+
521+
522+
@pytest.fixture(name="appliances_data")
523+
def appliances_data_fixture() -> str:
524+
"""Fixture to return a the string for an array of appliances."""
525+
return load_fixture("appliances.json", integration=DOMAIN)
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,121 @@
11
{
2-
"data": {
3-
"homeappliances": [
4-
{
5-
"name": "FridgeFreezer",
6-
"brand": "SIEMENS",
7-
"vib": "HCS05FRF1",
8-
"connected": true,
9-
"type": "FridgeFreezer",
10-
"enumber": "HCS05FRF1/03",
11-
"haId": "SIEMENS-HCS05FRF1-304F4F9E541D"
12-
},
13-
{
14-
"name": "Dishwasher",
15-
"brand": "SIEMENS",
16-
"vib": "HCS02DWH1",
17-
"connected": true,
18-
"type": "Dishwasher",
19-
"enumber": "HCS02DWH1/03",
20-
"haId": "SIEMENS-HCS02DWH1-6BE58C26DCC1"
21-
},
22-
{
23-
"name": "Oven",
24-
"brand": "BOSCH",
25-
"vib": "HCS01OVN1",
26-
"connected": true,
27-
"type": "Oven",
28-
"enumber": "HCS01OVN1/03",
29-
"haId": "BOSCH-HCS01OVN1-43E0065FE245"
30-
},
31-
{
32-
"name": "Washer",
33-
"brand": "SIEMENS",
34-
"vib": "HCS03WCH1",
35-
"connected": true,
36-
"type": "Washer",
37-
"enumber": "HCS03WCH1/03",
38-
"haId": "SIEMENS-HCS03WCH1-7BC6383CF794"
39-
},
40-
{
41-
"name": "Dryer",
42-
"brand": "BOSCH",
43-
"vib": "HCS04DYR1",
44-
"connected": true,
45-
"type": "Dryer",
46-
"enumber": "HCS04DYR1/03",
47-
"haId": "BOSCH-HCS04DYR1-831694AE3C5A"
48-
},
49-
{
50-
"name": "CoffeeMaker",
51-
"brand": "BOSCH",
52-
"vib": "HCS06COM1",
53-
"connected": true,
54-
"type": "CoffeeMaker",
55-
"enumber": "HCS06COM1/03",
56-
"haId": "BOSCH-HCS06COM1-D70390681C2C"
57-
},
58-
{
59-
"name": "WasherDryer",
60-
"brand": "BOSCH",
61-
"vib": "HCS000001",
62-
"connected": true,
63-
"type": "WasherDryer",
64-
"enumber": "HCS000000/01",
65-
"haId": "BOSCH-HCS000000-D00000000001"
66-
},
67-
{
68-
"name": "Refrigerator",
69-
"brand": "BOSCH",
70-
"vib": "HCS000002",
71-
"connected": true,
72-
"type": "Refrigerator",
73-
"enumber": "HCS000000/02",
74-
"haId": "BOSCH-HCS000000-D00000000002"
75-
},
76-
{
77-
"name": "Freezer",
78-
"brand": "BOSCH",
79-
"vib": "HCS000003",
80-
"connected": true,
81-
"type": "Freezer",
82-
"enumber": "HCS000000/03",
83-
"haId": "BOSCH-HCS000000-D00000000003"
84-
},
85-
{
86-
"name": "Hood",
87-
"brand": "BOSCH",
88-
"vib": "HCS000004",
89-
"connected": true,
90-
"type": "Hood",
91-
"enumber": "HCS000000/04",
92-
"haId": "BOSCH-HCS000000-D00000000004"
93-
},
94-
{
95-
"name": "Hob",
96-
"brand": "BOSCH",
97-
"vib": "HCS000005",
98-
"connected": true,
99-
"type": "Hob",
100-
"enumber": "HCS000000/05",
101-
"haId": "BOSCH-HCS000000-D00000000005"
102-
},
103-
{
104-
"name": "CookProcessor",
105-
"brand": "BOSCH",
106-
"vib": "HCS000006",
107-
"connected": true,
108-
"type": "CookProcessor",
109-
"enumber": "HCS000000/06",
110-
"haId": "BOSCH-HCS000000-D00000000006"
111-
},
112-
{
113-
"name": "DNE",
114-
"brand": "BOSCH",
115-
"vib": "HCS000000",
116-
"connected": true,
117-
"type": "DNE",
118-
"enumber": "HCS000000/00",
119-
"haId": "BOSCH-000000000-000000000000"
120-
}
121-
]
122-
}
2+
"homeappliances": [
3+
{
4+
"name": "FridgeFreezer",
5+
"brand": "SIEMENS",
6+
"vib": "HCS05FRF1",
7+
"connected": true,
8+
"type": "FridgeFreezer",
9+
"enumber": "HCS05FRF1/03",
10+
"haId": "SIEMENS-HCS05FRF1-304F4F9E541D"
11+
},
12+
{
13+
"name": "Dishwasher",
14+
"brand": "SIEMENS",
15+
"vib": "HCS02DWH1",
16+
"connected": true,
17+
"type": "Dishwasher",
18+
"enumber": "HCS02DWH1/03",
19+
"haId": "SIEMENS-HCS02DWH1-6BE58C26DCC1"
20+
},
21+
{
22+
"name": "Oven",
23+
"brand": "BOSCH",
24+
"vib": "HCS01OVN1",
25+
"connected": true,
26+
"type": "Oven",
27+
"enumber": "HCS01OVN1/03",
28+
"haId": "BOSCH-HCS01OVN1-43E0065FE245"
29+
},
30+
{
31+
"name": "Washer",
32+
"brand": "SIEMENS",
33+
"vib": "HCS03WCH1",
34+
"connected": true,
35+
"type": "Washer",
36+
"enumber": "HCS03WCH1/03",
37+
"haId": "SIEMENS-HCS03WCH1-7BC6383CF794"
38+
},
39+
{
40+
"name": "Dryer",
41+
"brand": "BOSCH",
42+
"vib": "HCS04DYR1",
43+
"connected": true,
44+
"type": "Dryer",
45+
"enumber": "HCS04DYR1/03",
46+
"haId": "BOSCH-HCS04DYR1-831694AE3C5A"
47+
},
48+
{
49+
"name": "CoffeeMaker",
50+
"brand": "BOSCH",
51+
"vib": "HCS06COM1",
52+
"connected": true,
53+
"type": "CoffeeMaker",
54+
"enumber": "HCS06COM1/03",
55+
"haId": "BOSCH-HCS06COM1-D70390681C2C"
56+
},
57+
{
58+
"name": "WasherDryer",
59+
"brand": "BOSCH",
60+
"vib": "HCS000001",
61+
"connected": true,
62+
"type": "WasherDryer",
63+
"enumber": "HCS000000/01",
64+
"haId": "BOSCH-HCS000000-D00000000001"
65+
},
66+
{
67+
"name": "Refrigerator",
68+
"brand": "BOSCH",
69+
"vib": "HCS000002",
70+
"connected": true,
71+
"type": "Refrigerator",
72+
"enumber": "HCS000000/02",
73+
"haId": "BOSCH-HCS000000-D00000000002"
74+
},
75+
{
76+
"name": "Freezer",
77+
"brand": "BOSCH",
78+
"vib": "HCS000003",
79+
"connected": true,
80+
"type": "Freezer",
81+
"enumber": "HCS000000/03",
82+
"haId": "BOSCH-HCS000000-D00000000003"
83+
},
84+
{
85+
"name": "Hood",
86+
"brand": "BOSCH",
87+
"vib": "HCS000004",
88+
"connected": true,
89+
"type": "Hood",
90+
"enumber": "HCS000000/04",
91+
"haId": "BOSCH-HCS000000-D00000000004"
92+
},
93+
{
94+
"name": "Hob",
95+
"brand": "BOSCH",
96+
"vib": "HCS000005",
97+
"connected": true,
98+
"type": "Hob",
99+
"enumber": "HCS000000/05",
100+
"haId": "BOSCH-HCS000000-D00000000005"
101+
},
102+
{
103+
"name": "CookProcessor",
104+
"brand": "BOSCH",
105+
"vib": "HCS000006",
106+
"connected": true,
107+
"type": "CookProcessor",
108+
"enumber": "HCS000000/06",
109+
"haId": "BOSCH-HCS000000-D00000000006"
110+
},
111+
{
112+
"name": "DNE",
113+
"brand": "BOSCH",
114+
"vib": "HCS000000",
115+
"connected": true,
116+
"type": "DNE",
117+
"enumber": "HCS000000/00",
118+
"haId": "BOSCH-000000000-000000000000"
119+
}
120+
]
123121
}

‎tests/components/home_connect/test_coordinator.py

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"""Test for Home Connect coordinator."""
22

33
from collections.abc import Awaitable, Callable
4-
import copy
54
from datetime import timedelta
6-
from typing import Any
5+
from typing import Any, cast
76
from unittest.mock import AsyncMock, MagicMock, patch
87

98
from aiohomeconnect.model import (
109
ArrayOfEvents,
10+
ArrayOfHomeAppliances,
1111
ArrayOfSettings,
1212
ArrayOfStatus,
1313
Event,
1414
EventKey,
1515
EventMessage,
1616
EventType,
17+
HomeAppliance,
1718
)
1819
from aiohomeconnect.model.error import (
1920
EventStreamInterruptedError,
@@ -42,8 +43,6 @@
4243
from homeassistant.setup import async_setup_component
4344
from homeassistant.util import dt as dt_util
4445

45-
from . import MOCK_APPLIANCES
46-
4746
from tests.common import MockConfigEntry, async_fire_time_changed
4847

4948

@@ -82,16 +81,21 @@ async def test_coordinator_update_failing_get_appliances(
8281

8382
@pytest.mark.usefixtures("setup_credentials")
8483
@pytest.mark.parametrize("platforms", [("binary_sensor",)])
85-
@pytest.mark.parametrize("appliance_ha_id", ["Washer"], indirect=True)
84+
@pytest.mark.parametrize("appliance", ["Washer"], indirect=True)
8685
async def test_coordinator_failure_refresh_and_stream(
8786
hass: HomeAssistant,
8887
config_entry: MockConfigEntry,
8988
integration_setup: Callable[[MagicMock], Awaitable[bool]],
9089
client: MagicMock,
9190
freezer: FrozenDateTimeFactory,
92-
appliance_ha_id: str,
91+
appliance: HomeAppliance,
9392
) -> None:
9493
"""Test entity available state via coordinator refresh and event stream."""
94+
appliance_data = (
95+
cast(str, appliance.to_json())
96+
.replace("ha_id", "haId")
97+
.replace("e_number", "enumber")
98+
)
9599
entity_id_1 = "binary_sensor.washer_remote_control"
96100
entity_id_2 = "binary_sensor.washer_remote_start"
97101
await async_setup_component(hass, "homeassistant", {})
@@ -122,7 +126,9 @@ async def test_coordinator_failure_refresh_and_stream(
122126
# Test that the entity becomes available again after a successful update.
123127

124128
client.get_home_appliances.side_effect = None
125-
client.get_home_appliances.return_value = copy.deepcopy(MOCK_APPLIANCES)
129+
client.get_home_appliances.return_value = ArrayOfHomeAppliances(
130+
[HomeAppliance.from_json(appliance_data)]
131+
)
126132

127133
# Move time forward to pass the debounce time.
128134
freezer.tick(timedelta(hours=1))
@@ -167,11 +173,13 @@ async def test_coordinator_failure_refresh_and_stream(
167173

168174
# Now make the entity available again.
169175
client.get_home_appliances.side_effect = None
170-
client.get_home_appliances.return_value = copy.deepcopy(MOCK_APPLIANCES)
176+
client.get_home_appliances.return_value = ArrayOfHomeAppliances(
177+
[HomeAppliance.from_json(appliance_data)]
178+
)
171179

172180
# One event should make all entities for this appliance available again.
173181
event_message = EventMessage(
174-
appliance_ha_id,
182+
appliance.ha_id,
175183
EventType.STATUS,
176184
ArrayOfEvents(
177185
[
@@ -400,6 +408,9 @@ async def test_event_listener_error(
400408
assert not config_entry._background_tasks
401409

402410

411+
@pytest.mark.usefixtures("setup_credentials")
412+
@pytest.mark.parametrize("platforms", [("sensor",)])
413+
@pytest.mark.parametrize("appliance", ["Washer"], indirect=True)
403414
@pytest.mark.parametrize(
404415
"exception",
405416
[HomeConnectRequestError(), EventStreamInterruptedError()],
@@ -430,11 +441,10 @@ async def test_event_listener_resilience(
430441
after_event_expected_state: str,
431442
exception: HomeConnectError,
432443
hass: HomeAssistant,
444+
appliance: HomeAppliance,
445+
client: MagicMock,
433446
config_entry: MockConfigEntry,
434447
integration_setup: Callable[[MagicMock], Awaitable[bool]],
435-
setup_credentials: None,
436-
client: MagicMock,
437-
appliance_ha_id: str,
438448
) -> None:
439449
"""Test that the event listener is resilient to interruptions."""
440450
future = hass.loop.create_future()
@@ -468,7 +478,7 @@ async def stream_exception():
468478
await client.add_events(
469479
[
470480
EventMessage(
471-
appliance_ha_id,
481+
appliance.ha_id,
472482
EventType.STATUS,
473483
ArrayOfEvents(
474484
[

0 commit comments

Comments
 (0)
Please sign in to comment.