Skip to content

Commit

Permalink
Use snapshots in Linear diagnostics tests (home-assistant#116169)
Browse files Browse the repository at this point in the history
* Use snapshots in Linear diagnostics tests

* Use snapshots in Linear diagnostics tests
  • Loading branch information
joostlek authored Apr 25, 2024
1 parent 1e06054 commit 860ac45
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# serializer version: 1
# name: test_entry_diagnostics
dict({
'coordinator_data': dict({
'test1': dict({
'name': 'Test Garage 1',
'subdevices': dict({
'GDO': dict({
'Open_B': 'true',
'Open_P': '100',
}),
'Light': dict({
'On_B': 'true',
'On_P': '100',
}),
}),
}),
'test2': dict({
'name': 'Test Garage 2',
'subdevices': dict({
'GDO': dict({
'Open_B': 'false',
'Open_P': '0',
}),
'Light': dict({
'On_B': 'false',
'On_P': '0',
}),
}),
}),
'test3': dict({
'name': 'Test Garage 3',
'subdevices': dict({
'GDO': dict({
'Open_B': 'false',
'Opening_P': '0',
}),
'Light': dict({
'On_B': 'false',
'On_P': '0',
}),
}),
}),
'test4': dict({
'name': 'Test Garage 4',
'subdevices': dict({
'GDO': dict({
'Open_B': 'true',
'Opening_P': '100',
}),
'Light': dict({
'On_B': 'true',
'On_P': '100',
}),
}),
}),
}),
'entry': dict({
'data': dict({
'device_id': 'test-uuid',
'email': '**REDACTED**',
'password': '**REDACTED**',
'site_id': 'test-site-id',
}),
'disabled_by': None,
'domain': 'linear_garage_door',
'entry_id': 'acefdd4b3a4a0911067d1cf51414201e',
'minor_version': 1,
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'title': 'Mock Title',
'unique_id': None,
'version': 1,
}),
})
# ---
44 changes: 6 additions & 38 deletions tests/components/linear_garage_door/test_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test diagnostics of Linear Garage Door."""

from syrupy import SnapshotAssertion

from homeassistant.core import HomeAssistant

from .util import async_init_integration
Expand All @@ -9,45 +11,11 @@


async def test_entry_diagnostics(
hass: HomeAssistant, hass_client: ClientSessionGenerator
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
entry = await async_init_integration(hass)
result = await get_diagnostics_for_config_entry(hass, hass_client, entry)

assert result["entry"]["data"] == {
"email": "**REDACTED**",
"password": "**REDACTED**",
"site_id": "test-site-id",
"device_id": "test-uuid",
}
assert result["coordinator_data"] == {
"test1": {
"name": "Test Garage 1",
"subdevices": {
"GDO": {"Open_B": "true", "Open_P": "100"},
"Light": {"On_B": "true", "On_P": "100"},
},
},
"test2": {
"name": "Test Garage 2",
"subdevices": {
"GDO": {"Open_B": "false", "Open_P": "0"},
"Light": {"On_B": "false", "On_P": "0"},
},
},
"test3": {
"name": "Test Garage 3",
"subdevices": {
"GDO": {"Open_B": "false", "Opening_P": "0"},
"Light": {"On_B": "false", "On_P": "0"},
},
},
"test4": {
"name": "Test Garage 4",
"subdevices": {
"GDO": {"Open_B": "true", "Opening_P": "100"},
"Light": {"On_B": "true", "On_P": "100"},
},
},
}
assert result == snapshot
1 change: 1 addition & 0 deletions tests/components/linear_garage_door/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async def async_init_integration(hass: HomeAssistant) -> MockConfigEntry:
"""Initialize mock integration."""
config_entry = MockConfigEntry(
domain=DOMAIN,
entry_id="acefdd4b3a4a0911067d1cf51414201e",
data={
"email": "test-email",
"password": "test-password",
Expand Down

0 comments on commit 860ac45

Please sign in to comment.