2022-01-20 00:52:20 +01:00
|
|
|
"""Test the Netatmo diagnostics."""
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
|
2023-09-01 19:27:54 +02:00
|
|
|
from syrupy import SnapshotAssertion
|
|
|
|
from syrupy.filters import paths
|
|
|
|
|
2023-02-15 10:00:49 +01:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-01-20 00:52:20 +01:00
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
|
|
|
|
from .common import fake_post_request
|
|
|
|
|
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-02-15 10:00:49 +01:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2022-01-20 00:52:20 +01:00
|
|
|
|
|
|
|
|
2023-02-15 10:00:49 +01:00
|
|
|
async def test_entry_diagnostics(
|
2023-09-01 19:27:54 +02:00
|
|
|
hass: HomeAssistant,
|
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
config_entry,
|
2023-02-15 10:00:49 +01:00
|
|
|
) -> None:
|
2022-01-20 00:52:20 +01:00
|
|
|
"""Test config entry diagnostics."""
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth",
|
|
|
|
) as mock_auth, patch(
|
|
|
|
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
|
|
|
|
), patch(
|
|
|
|
"homeassistant.components.netatmo.webhook_generate_url"
|
|
|
|
):
|
2022-09-26 03:55:58 +02:00
|
|
|
mock_auth.return_value.async_post_api_request.side_effect = fake_post_request
|
2022-01-20 00:52:20 +01:00
|
|
|
mock_auth.return_value.async_addwebhook.side_effect = AsyncMock()
|
|
|
|
mock_auth.return_value.async_dropwebhook.side_effect = AsyncMock()
|
|
|
|
assert await async_setup_component(hass, "netatmo", {})
|
|
|
|
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
2023-09-01 19:27:54 +02:00
|
|
|
assert await get_diagnostics_for_config_entry(
|
|
|
|
hass, hass_client, config_entry
|
|
|
|
) == snapshot(exclude=paths("info.data.token.expires_at", "info.entry_id"))
|