mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 03:03:17 +01:00
Fix execution history matching to ignore subsystem suffix in diagnostics in Overkiz (#160218)
This commit is contained in:
@@ -61,7 +61,10 @@ async def async_get_device_diagnostics(
|
||||
data["execution_history"] = [
|
||||
repr(execution)
|
||||
for execution in await client.get_execution_history()
|
||||
if any(command.device_url == device_url for command in execution.commands)
|
||||
if any(
|
||||
command.device_url.split("#", 1)[0] == device_url.split("#", 1)[0]
|
||||
for command in execution.commands
|
||||
)
|
||||
]
|
||||
|
||||
return data
|
||||
|
||||
@@ -66,3 +66,49 @@ async def test_device_diagnostics(
|
||||
)
|
||||
== snapshot
|
||||
)
|
||||
|
||||
|
||||
async def test_device_diagnostics_execution_history_subsystem(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
init_integration: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test execution history matching ignores subsystem suffix."""
|
||||
|
||||
diagnostic_data = await async_load_json_object_fixture(
|
||||
hass, "setup_tahoma_switch.json", DOMAIN
|
||||
)
|
||||
|
||||
device = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, "rts://****-****-6867/16756006")}
|
||||
)
|
||||
assert device is not None
|
||||
|
||||
class _FakeCommand:
|
||||
def __init__(self, device_url: str) -> None:
|
||||
self.device_url = device_url
|
||||
|
||||
class _FakeExecution:
|
||||
def __init__(self, name: str, device_urls: list[str]) -> None:
|
||||
self.name = name
|
||||
self.commands = [_FakeCommand(device_url) for device_url in device_urls]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"Execution({self.name})"
|
||||
|
||||
execution_history = [
|
||||
_FakeExecution("matching", ["rts://****-****-6867/16756006#2"]),
|
||||
_FakeExecution("other", ["rts://****-****-6867/other_device"]),
|
||||
]
|
||||
|
||||
with patch.multiple(
|
||||
"pyoverkiz.client.OverkizClient",
|
||||
get_diagnostic_data=AsyncMock(return_value=diagnostic_data),
|
||||
get_execution_history=AsyncMock(return_value=execution_history),
|
||||
):
|
||||
diagnostics = await get_diagnostics_for_device(
|
||||
hass, hass_client, init_integration, device
|
||||
)
|
||||
|
||||
assert diagnostics["execution_history"] == ["Execution(matching)"]
|
||||
|
||||
Reference in New Issue
Block a user