1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Use snapshot assertion for Co2signal diagnostics test (#98905)

This commit is contained in:
Joost Lekkerkerker
2023-08-24 01:18:49 +02:00
committed by GitHub
parent a1307e117d
commit faa4489f4c
2 changed files with 42 additions and 10 deletions

View File

@@ -1,8 +1,9 @@
"""Test the CO2Signal diagnostics."""
from unittest.mock import patch
from syrupy import SnapshotAssertion
from homeassistant.components.co2signal import DOMAIN
from homeassistant.components.diagnostics import REDACTED
from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@@ -15,11 +16,15 @@ from tests.typing import ClientSessionGenerator
async def test_entry_diagnostics(
hass: HomeAssistant, hass_client: ClientSessionGenerator
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_API_KEY: "api_key", "location": ""}
domain=DOMAIN,
data={CONF_API_KEY: "api_key", "location": ""},
entry_id="904a74160aa6f335526706bee85dfb83",
)
config_entry.add_to_hass(hass)
with patch("CO2Signal.get_latest", return_value=VALID_PAYLOAD):
@@ -27,10 +32,4 @@ async def test_entry_diagnostics(
result = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
config_entry_dict = config_entry.as_dict()
config_entry_dict["data"][CONF_API_KEY] = REDACTED
assert result == {
"config_entry": config_entry_dict,
"data": VALID_PAYLOAD,
}
assert result == snapshot