Use snapshot assertion for Ridwell diagnostics test (#98919)

pull/97467/head
Joost Lekkerkerker 2023-08-24 08:14:46 +02:00 committed by GitHub
parent 46a0f84101
commit 14f80560c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 44 deletions

View File

@ -56,7 +56,12 @@ def client_fixture(account):
@pytest.fixture(name="config_entry")
def config_entry_fixture(hass, config):
"""Define a config entry fixture."""
entry = MockConfigEntry(domain=DOMAIN, unique_id=config[CONF_USERNAME], data=config)
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=config[CONF_USERNAME],
data=config,
entry_id="11554ec901379b9cc8f5a6c1d11ce978",
)
entry.add_to_hass(hass)
return entry

View File

@ -0,0 +1,49 @@
# serializer version: 1
# name: test_entry_diagnostics
dict({
'data': list([
dict({
'_async_request': None,
'event_id': 'event_123',
'pickup_date': dict({
'__type': "<class 'datetime.date'>",
'isoformat': '2022-01-24',
}),
'pickups': list([
dict({
'category': dict({
'__type': "<enum 'PickupCategory'>",
'repr': "<PickupCategory.STANDARD: 'standard'>",
}),
'name': 'Plastic Film',
'offer_id': 'offer_123',
'priority': 1,
'product_id': 'product_123',
'quantity': 1,
}),
]),
'state': dict({
'__type': "<enum 'EventState'>",
'repr': "<EventState.INITIALIZED: 'initialized'>",
}),
}),
]),
'entry': dict({
'data': dict({
'password': '**REDACTED**',
'username': '**REDACTED**',
}),
'disabled_by': None,
'domain': 'ridwell',
'entry_id': '11554ec901379b9cc8f5a6c1d11ce978',
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'title': '**REDACTED**',
'unique_id': '**REDACTED**',
'version': 2,
}),
})
# ---

View File

@ -1,5 +1,6 @@
"""Test Ridwell diagnostics."""
from homeassistant.components.diagnostics import REDACTED
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
from tests.components.diagnostics import get_diagnostics_for_config_entry
@ -11,47 +12,10 @@ async def test_entry_diagnostics(
config_entry,
hass_client: ClientSessionGenerator,
setup_config_entry,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
"entry": {
"entry_id": config_entry.entry_id,
"version": 2,
"domain": "ridwell",
"title": REDACTED,
"data": {"username": REDACTED, "password": REDACTED},
"options": {},
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"source": "user",
"unique_id": REDACTED,
"disabled_by": None,
},
"data": [
{
"_async_request": None,
"event_id": "event_123",
"pickup_date": {
"__type": "<class 'datetime.date'>",
"isoformat": "2022-01-24",
},
"pickups": [
{
"name": "Plastic Film",
"offer_id": "offer_123",
"priority": 1,
"product_id": "product_123",
"quantity": 1,
"category": {
"__type": "<enum 'PickupCategory'>",
"repr": "<PickupCategory.STANDARD: 'standard'>",
},
}
],
"state": {
"__type": "<enum 'EventState'>",
"repr": "<EventState.INITIALIZED: 'initialized'>",
},
}
],
}
assert (
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
== snapshot
)