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