2022-10-28 04:38:11 +00:00
|
|
|
"""Test Environment Canada diagnostics."""
|
2024-03-08 13:50:25 +00:00
|
|
|
|
2022-10-28 04:38:11 +00:00
|
|
|
import json
|
2024-08-15 14:14:01 +00:00
|
|
|
from typing import Any
|
2022-10-28 04:38:11 +00:00
|
|
|
|
2023-08-23 20:21:24 +00:00
|
|
|
from syrupy import SnapshotAssertion
|
|
|
|
|
2024-07-16 09:57:37 +00:00
|
|
|
from homeassistant.components.environment_canada.const import CONF_STATION
|
2023-12-13 16:05:37 +00:00
|
|
|
from homeassistant.const import CONF_LANGUAGE, CONF_LATITUDE, CONF_LONGITUDE
|
2022-10-28 04:38:11 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
2024-07-16 09:57:37 +00:00
|
|
|
from . import init_integration
|
|
|
|
|
|
|
|
from tests.common import load_fixture
|
2022-10-28 04:38:11 +00:00
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-02-08 12:01:44 +00:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2022-10-28 04:38:11 +00:00
|
|
|
|
|
|
|
FIXTURE_USER_INPUT = {
|
|
|
|
CONF_LATITUDE: 55.55,
|
|
|
|
CONF_LONGITUDE: 42.42,
|
|
|
|
CONF_STATION: "XX/1234567",
|
|
|
|
CONF_LANGUAGE: "Gibberish",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-08 12:01:44 +00:00
|
|
|
async def test_entry_diagnostics(
|
2023-08-23 20:21:24 +00:00
|
|
|
hass: HomeAssistant,
|
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
snapshot: SnapshotAssertion,
|
2024-08-15 14:14:01 +00:00
|
|
|
ec_data: dict[str, Any],
|
2023-02-08 12:01:44 +00:00
|
|
|
) -> None:
|
2022-10-28 04:38:11 +00:00
|
|
|
"""Test config entry diagnostics."""
|
|
|
|
|
2024-07-16 09:57:37 +00:00
|
|
|
ec_data = json.loads(
|
|
|
|
load_fixture("environment_canada/current_conditions_data.json")
|
|
|
|
)
|
|
|
|
|
|
|
|
config_entry = await init_integration(hass, ec_data)
|
2022-10-28 04:38:11 +00:00
|
|
|
diagnostics = await get_diagnostics_for_config_entry(
|
|
|
|
hass, hass_client, config_entry
|
|
|
|
)
|
|
|
|
|
2023-08-23 20:21:24 +00:00
|
|
|
assert diagnostics == snapshot
|