Use snapshot assertion for google assistant diagnostics test (#99167)

pull/99327/head
Jan-Philipp Benecke 2023-08-30 12:25:06 +02:00 committed by GitHub
parent fb42042402
commit 027ce55fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 119 additions and 83 deletions

View File

@ -0,0 +1,110 @@
# serializer version: 1
# name: test_diagnostics
dict({
'config_entry': dict({
'data': dict({
'project_id': '1234',
}),
'disabled_by': None,
'domain': 'google_assistant',
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'import',
'title': '1234',
'unique_id': '1234',
'version': 1,
}),
'query': dict({
'devices': dict({
'switch.ac': dict({
'on': False,
'online': True,
}),
'switch.decorative_lights': dict({
'on': True,
'online': True,
}),
}),
}),
'sync': dict({
'agentUserId': '**REDACTED**',
'devices': list([
dict({
'attributes': dict({
'commandOnlyOnOff': True,
}),
'customData': dict({
'httpPort': 8123,
'uuid': '**REDACTED**',
'webhookId': None,
}),
'id': 'switch.decorative_lights',
'name': dict({
'name': 'Decorative Lights',
}),
'otherDeviceIds': list([
dict({
'deviceId': 'switch.decorative_lights',
}),
]),
'traits': list([
'action.devices.traits.OnOff',
]),
'type': 'action.devices.types.SWITCH',
'willReportState': False,
}),
dict({
'attributes': dict({
}),
'customData': dict({
'httpPort': 8123,
'uuid': '**REDACTED**',
'webhookId': None,
}),
'id': 'switch.ac',
'name': dict({
'name': 'AC',
}),
'otherDeviceIds': list([
dict({
'deviceId': 'switch.ac',
}),
]),
'traits': list([
'action.devices.traits.OnOff',
]),
'type': 'action.devices.types.OUTLET',
'willReportState': False,
}),
]),
}),
'yaml_config': dict({
'expose_by_default': True,
'exposed_domains': list([
'alarm_control_panel',
'binary_sensor',
'climate',
'cover',
'fan',
'group',
'humidifier',
'input_boolean',
'input_select',
'light',
'lock',
'media_player',
'scene',
'script',
'select',
'sensor',
'switch',
'vacuum',
]),
'project_id': '1234',
'report_state': False,
'service_account': '**REDACTED**',
}),
})
# ---

View File

@ -1,7 +1,9 @@
"""Test diagnostics.""" """Test diagnostics."""
from unittest.mock import ANY, patch from unittest.mock import patch
import pytest import pytest
from syrupy import SnapshotAssertion
from syrupy.filters import props
from homeassistant import setup from homeassistant import setup
from homeassistant.components import google_assistant as ga, switch from homeassistant.components import google_assistant as ga, switch
@ -26,7 +28,9 @@ async def switch_only() -> None:
async def test_diagnostics( async def test_diagnostics(
hass: HomeAssistant, hass_client: ClientSessionGenerator hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test diagnostics v1.""" """Test diagnostics v1."""
@ -42,84 +46,6 @@ async def test_diagnostics(
) )
config_entry = hass.config_entries.async_entries("google_assistant")[0] config_entry = hass.config_entries.async_entries("google_assistant")[0]
result = await get_diagnostics_for_config_entry(hass, hass_client, config_entry) assert await get_diagnostics_for_config_entry(
assert result == { hass, hass_client, config_entry
"config_entry": { ) == snapshot(exclude=props("entry_id"))
"data": {"project_id": "1234"},
"disabled_by": None,
"domain": "google_assistant",
"entry_id": ANY,
"options": {},
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"source": "import",
"title": "1234",
"unique_id": "1234",
"version": 1,
},
"sync": {
"agentUserId": "**REDACTED**",
"devices": [
{
"attributes": {"commandOnlyOnOff": True},
"id": "switch.decorative_lights",
"otherDeviceIds": [{"deviceId": "switch.decorative_lights"}],
"name": {"name": "Decorative Lights"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.SWITCH",
"willReportState": False,
"customData": {
"httpPort": 8123,
"uuid": "**REDACTED**",
"webhookId": None,
},
},
{
"attributes": {},
"id": "switch.ac",
"otherDeviceIds": [{"deviceId": "switch.ac"}],
"name": {"name": "AC"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.OUTLET",
"willReportState": False,
"customData": {
"httpPort": 8123,
"uuid": "**REDACTED**",
"webhookId": None,
},
},
],
},
"query": {
"devices": {
"switch.ac": {"on": False, "online": True},
"switch.decorative_lights": {"on": True, "online": True},
}
},
"yaml_config": {
"expose_by_default": True,
"exposed_domains": [
"alarm_control_panel",
"binary_sensor",
"climate",
"cover",
"fan",
"group",
"humidifier",
"input_boolean",
"input_select",
"light",
"lock",
"media_player",
"scene",
"script",
"select",
"sensor",
"switch",
"vacuum",
],
"project_id": "1234",
"report_state": False,
"service_account": "**REDACTED**",
},
}