Add snapshot assertion to Airzone cloud (#98761)

This commit is contained in:
Joost Lekkerkerker 2023-08-22 09:30:43 +02:00 committed by GitHub
parent a89c0c944a
commit d4b49726f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 239 additions and 46 deletions

View File

@ -0,0 +1,231 @@
# serializer version: 1
# name: test_config_entry_diagnostics
dict({
'api_data': dict({
'devices-config': dict({
'device1': dict({
}),
}),
'devices-status': dict({
'device1': dict({
}),
}),
'installations': dict({
'installation1': dict({
'groups': list([
dict({
'devices': list([
dict({
'device_id': 'device1',
'ws_id': 'webserver1',
}),
]),
'group_id': 'group1',
}),
]),
'plugins': dict({
'schedules': dict({
'calendar_ws_ids': list([
'webserver1',
]),
}),
}),
}),
}),
'installations-list': dict({
}),
'test_cov': dict({
'1': None,
'2': list([
'foo',
'bar',
]),
'3': list([
list([
'foo',
'bar',
]),
]),
}),
'webservers': dict({
'webserver1': dict({
}),
}),
}),
'config_entry': dict({
'data': dict({
'id': 'installation1',
'password': '**REDACTED**',
'username': '**REDACTED**',
}),
'disabled_by': None,
'domain': 'airzone_cloud',
'entry_id': 'd186e31edb46d64d14b9b2f11f1ebd9f',
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'title': 'Mock Title',
'unique_id': 'installation1',
'version': 1,
}),
'coord_data': dict({
'aidoos': dict({
'aidoo1': dict({
'action': 6,
'active': False,
'available': True,
'id': 'aidoo1',
'installation': 'installation1',
'is-connected': True,
'mode': None,
'name': 'Bron',
'power': None,
'problems': False,
'temperature': 21.0,
'temperature-step': 0.5,
'web-server': '11:22:33:44:55:67',
'ws-connected': True,
}),
}),
'groups': dict({
'group1': dict({
'action': 6,
'active': True,
'available': True,
'humidity': 27,
'installation': 'installation1',
'mode': 0,
'name': 'Group',
'num-devices': 2,
'power': None,
'systems': list([
'system1',
]),
'temperature': 22.5,
'temperature-step': 0.5,
'zones': list([
'zone1',
'zone2',
]),
}),
'grp2': dict({
'action': 6,
'active': False,
'aidoos': list([
'aidoo1',
]),
'available': True,
'installation': 'installation1',
'mode': 0,
'name': 'Aidoo Group',
'num-devices': 1,
'power': None,
'temperature': 21.0,
'temperature-step': 0.5,
}),
}),
'installations': dict({
'installation1': dict({
'id': 'installation1',
'name': 'House',
'web-servers': list([
'webserver1',
'11:22:33:44:55:67',
]),
}),
}),
'systems': dict({
'system1': dict({
'available': True,
'id': 'system1',
'installation': 'installation1',
'is-connected': True,
'mode': None,
'name': 'System 1',
'problems': False,
'system': 1,
'web-server': 'webserver1',
'ws-connected': True,
}),
}),
'web-servers': dict({
'11:22:33:44:55:67': dict({
'available': True,
'connection-date': '2023-05-24 17:00:52 +0200',
'disconnection-date': '2023-05-24 17:00:25 +0200',
'firmware': '3.13',
'id': '11:22:33:44:55:67',
'installation': 'installation1',
'name': 'WebServer 11:22:33:44:55:67',
'type': 'ws_aidoo',
'wifi-channel': 1,
'wifi-mac': '**REDACTED**',
'wifi-quality': 4,
'wifi-rssi': -77,
'wifi-ssid': 'Wifi',
}),
'webserver1': dict({
'available': True,
'connection-date': '2023-05-07T12:55:51.000Z',
'disconnection-date': '2023-01-01T22:26:55.376Z',
'firmware': '3.44',
'id': 'webserver1',
'installation': 'installation1',
'name': 'WebServer 11:22:33:44:55:66',
'type': 'ws_az',
'wifi-channel': 36,
'wifi-mac': '**REDACTED**',
'wifi-quality': 4,
'wifi-rssi': -56,
'wifi-ssid': 'Wifi',
}),
}),
'zones': dict({
'zone1': dict({
'action': 6,
'active': True,
'available': True,
'humidity': 30,
'id': 'zone1',
'installation': 'installation1',
'is-connected': True,
'master': None,
'mode': None,
'name': 'Salon',
'power': None,
'problems': False,
'system': 1,
'system-id': 'system1',
'temperature': 20.0,
'temperature-step': 0.5,
'web-server': 'webserver1',
'ws-connected': True,
'zone': 1,
}),
'zone2': dict({
'action': 6,
'active': False,
'available': True,
'humidity': 24,
'id': 'zone2',
'installation': 'installation1',
'is-connected': True,
'master': None,
'mode': None,
'name': 'Dormitorio',
'power': None,
'problems': False,
'system': 1,
'system-id': 'system1',
'temperature': 25.0,
'temperature-step': 0.5,
'web-server': 'webserver1',
'ws-connected': True,
'zone': 2,
}),
}),
}),
})
# ---

View File

@ -8,22 +8,16 @@ from aioairzone_cloud.const import (
API_GROUP_ID,
API_GROUPS,
API_WS_ID,
AZD_AIDOOS,
AZD_GROUPS,
AZD_INSTALLATIONS,
AZD_SYSTEMS,
AZD_WEBSERVERS,
AZD_ZONES,
RAW_DEVICES_CONFIG,
RAW_DEVICES_STATUS,
RAW_INSTALLATIONS,
RAW_INSTALLATIONS_LIST,
RAW_WEBSERVERS,
)
from syrupy import SnapshotAssertion
from homeassistant.components.airzone_cloud.const import DOMAIN
from homeassistant.components.diagnostics import REDACTED
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import CONF_ID
from homeassistant.core import HomeAssistant
from .util import CONFIG, WS_ID, async_init_integration
@ -78,7 +72,9 @@ RAW_DATA_MOCK = {
async def test_config_entry_diagnostics(
hass: HomeAssistant, hass_client: ClientSessionGenerator
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
await async_init_integration(hass)
@ -89,40 +85,5 @@ async def test_config_entry_diagnostics(
"homeassistant.components.airzone_cloud.AirzoneCloudApi.raw_data",
return_value=RAW_DATA_MOCK,
):
diag = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
assert list(diag["api_data"]) >= list(RAW_DATA_MOCK)
assert "dev1" not in diag["api_data"][RAW_DEVICES_CONFIG]
assert "device1" in diag["api_data"][RAW_DEVICES_CONFIG]
assert (
diag["api_data"][RAW_INSTALLATIONS]["installation1"][API_GROUPS][0][
API_GROUP_ID
]
== "group1"
)
assert "inst1" not in diag["api_data"][RAW_INSTALLATIONS]
assert "installation1" in diag["api_data"][RAW_INSTALLATIONS]
assert WS_ID not in diag["api_data"][RAW_WEBSERVERS]
assert "webserver1" in diag["api_data"][RAW_WEBSERVERS]
assert (
diag["config_entry"].items()
>= {
"data": {
CONF_ID: "installation1",
CONF_PASSWORD: REDACTED,
CONF_USERNAME: REDACTED,
},
"domain": DOMAIN,
"unique_id": "installation1",
}.items()
)
assert list(diag["coord_data"]) >= [
AZD_AIDOOS,
AZD_GROUPS,
AZD_INSTALLATIONS,
AZD_SYSTEMS,
AZD_WEBSERVERS,
AZD_ZONES,
]
result = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
assert result == snapshot

View File

@ -223,6 +223,7 @@ async def async_init_integration(
config_entry = MockConfigEntry(
data=CONFIG,
entry_id="d186e31edb46d64d14b9b2f11f1ebd9f",
domain=DOMAIN,
unique_id=CONFIG[CONF_ID],
)