2022-01-24 03:10:42 -07:00
|
|
|
"""Test RainMachine diagnostics."""
|
2024-03-08 14:47:22 +01:00
|
|
|
|
2022-08-07 15:21:49 -06:00
|
|
|
from regenmaschine.errors import RainMachineError
|
2024-05-23 16:22:31 +02:00
|
|
|
from syrupy import SnapshotAssertion
|
2024-07-29 22:08:46 +02:00
|
|
|
from syrupy.filters import props
|
2022-08-07 15:21:49 -06:00
|
|
|
|
2023-02-15 11:14:04 +01:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-01-24 03:10:42 -07:00
|
|
|
|
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-02-15 11:14:04 +01:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2022-01-24 03:10:42 -07:00
|
|
|
|
|
|
|
|
2023-02-15 11:14:04 +01:00
|
|
|
async def test_entry_diagnostics(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
config_entry,
|
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
setup_rainmachine,
|
2024-05-23 16:22:31 +02:00
|
|
|
snapshot: SnapshotAssertion,
|
2023-02-15 11:14:04 +01:00
|
|
|
) -> None:
|
2022-01-24 03:10:42 -07:00
|
|
|
"""Test config entry diagnostics."""
|
2024-07-29 22:08:46 +02:00
|
|
|
assert await get_diagnostics_for_config_entry(
|
|
|
|
hass, hass_client, config_entry
|
|
|
|
) == snapshot(exclude=props("created_at", "modified_at"))
|
2022-08-07 15:21:49 -06:00
|
|
|
|
|
|
|
|
|
|
|
async def test_entry_diagnostics_failed_controller_diagnostics(
|
2023-02-15 11:14:04 +01:00
|
|
|
hass: HomeAssistant,
|
|
|
|
config_entry,
|
|
|
|
controller,
|
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
setup_rainmachine,
|
2024-05-23 16:22:31 +02:00
|
|
|
snapshot: SnapshotAssertion,
|
2023-02-15 11:14:04 +01:00
|
|
|
) -> None:
|
2022-08-07 15:21:49 -06:00
|
|
|
"""Test config entry diagnostics when the controller diagnostics API call fails."""
|
|
|
|
controller.diagnostics.current.side_effect = RainMachineError
|
2024-07-29 22:08:46 +02:00
|
|
|
assert await get_diagnostics_for_config_entry(
|
|
|
|
hass, hass_client, config_entry
|
|
|
|
) == snapshot(exclude=props("created_at", "modified_at"))
|