mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix yale_smart_alarm on missing key (#125508)
This commit is contained in:
parent
c0ee12ca41
commit
26ede9a679
@ -154,10 +154,15 @@ class YaleDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
except YALE_BASE_ERRORS as error:
|
except YALE_BASE_ERRORS as error:
|
||||||
raise UpdateFailed from error
|
raise UpdateFailed from error
|
||||||
|
|
||||||
|
cycle = data.cycle["data"] if data.cycle else None
|
||||||
|
status = data.status["data"] if data.status else None
|
||||||
|
online = data.online["data"] if data.online else None
|
||||||
|
panel_info = data.panel_info["data"] if data.panel_info else None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"arm_status": arm_status,
|
"arm_status": arm_status,
|
||||||
"cycle": data.cycle,
|
"cycle": cycle,
|
||||||
"status": data.status,
|
"status": status,
|
||||||
"online": data.online,
|
"online": online,
|
||||||
"panel_info": data.panel_info,
|
"panel_info": panel_info,
|
||||||
}
|
}
|
||||||
|
@ -82,10 +82,10 @@ def get_fixture_data() -> dict[str, Any]:
|
|||||||
def get_update_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
def get_update_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
||||||
"""Load update data and return."""
|
"""Load update data and return."""
|
||||||
|
|
||||||
status = loaded_fixture["STATUS"]
|
status = {"data": loaded_fixture["STATUS"]}
|
||||||
cycle = loaded_fixture["CYCLE"]
|
cycle = {"data": loaded_fixture["CYCLE"]}
|
||||||
online = loaded_fixture["ONLINE"]
|
online = {"data": loaded_fixture["ONLINE"]}
|
||||||
panel_info = loaded_fixture["PANEL INFO"]
|
panel_info = {"data": loaded_fixture["PANEL INFO"]}
|
||||||
return YaleSmartAlarmData(
|
return YaleSmartAlarmData(
|
||||||
status=status,
|
status=status,
|
||||||
cycle=cycle,
|
cycle=cycle,
|
||||||
@ -98,14 +98,14 @@ def get_update_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
|||||||
def get_diag_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
def get_diag_data(loaded_fixture: dict[str, Any]) -> YaleSmartAlarmData:
|
||||||
"""Load all data and return."""
|
"""Load all data and return."""
|
||||||
|
|
||||||
devices = loaded_fixture["DEVICES"]
|
devices = {"data": loaded_fixture["DEVICES"]}
|
||||||
mode = loaded_fixture["MODE"]
|
mode = {"data": loaded_fixture["MODE"]}
|
||||||
status = loaded_fixture["STATUS"]
|
status = {"data": loaded_fixture["STATUS"]}
|
||||||
cycle = loaded_fixture["CYCLE"]
|
cycle = {"data": loaded_fixture["CYCLE"]}
|
||||||
online = loaded_fixture["ONLINE"]
|
online = {"data": loaded_fixture["ONLINE"]}
|
||||||
history = loaded_fixture["HISTORY"]
|
history = {"data": loaded_fixture["HISTORY"]}
|
||||||
panel_info = loaded_fixture["PANEL INFO"]
|
panel_info = {"data": loaded_fixture["PANEL INFO"]}
|
||||||
auth_check = loaded_fixture["AUTH CHECK"]
|
auth_check = {"data": loaded_fixture["AUTH CHECK"]}
|
||||||
return YaleSmartAlarmData(
|
return YaleSmartAlarmData(
|
||||||
devices=devices,
|
devices=devices,
|
||||||
mode=mode,
|
mode=mode,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@ async def test_lock_service_calls(
|
|||||||
client = load_config_entry[1]
|
client = load_config_entry[1]
|
||||||
|
|
||||||
data = deepcopy(get_data.cycle)
|
data = deepcopy(get_data.cycle)
|
||||||
data["data"] = data.pop("device_status")
|
data["data"] = data["data"].pop("device_status")
|
||||||
|
|
||||||
client.auth.get_authenticated = Mock(return_value=data)
|
client.auth.get_authenticated = Mock(return_value=data)
|
||||||
client.auth.post_authenticated = Mock(return_value={"code": "000"})
|
client.auth.post_authenticated = Mock(return_value={"code": "000"})
|
||||||
@ -109,7 +109,7 @@ async def test_lock_service_call_fails(
|
|||||||
client = load_config_entry[1]
|
client = load_config_entry[1]
|
||||||
|
|
||||||
data = deepcopy(get_data.cycle)
|
data = deepcopy(get_data.cycle)
|
||||||
data["data"] = data.pop("device_status")
|
data["data"] = data["data"].pop("device_status")
|
||||||
|
|
||||||
client.auth.get_authenticated = Mock(return_value=data)
|
client.auth.get_authenticated = Mock(return_value=data)
|
||||||
client.auth.post_authenticated = Mock(side_effect=UnknownError("test_side_effect"))
|
client.auth.post_authenticated = Mock(side_effect=UnknownError("test_side_effect"))
|
||||||
@ -161,7 +161,7 @@ async def test_lock_service_call_fails_with_incorrect_status(
|
|||||||
client = load_config_entry[1]
|
client = load_config_entry[1]
|
||||||
|
|
||||||
data = deepcopy(get_data.cycle)
|
data = deepcopy(get_data.cycle)
|
||||||
data["data"] = data.pop("device_status")
|
data["data"] = data["data"].pop("device_status")
|
||||||
|
|
||||||
client.auth.get_authenticated = Mock(return_value=data)
|
client.auth.get_authenticated = Mock(return_value=data)
|
||||||
client.auth.post_authenticated = Mock(return_value={"code": "FFF"})
|
client.auth.post_authenticated = Mock(return_value={"code": "FFF"})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user