"""Test the Husqvarna Automower Diagnostics.""" import datetime from unittest.mock import AsyncMock import pytest from syrupy.assertion import SnapshotAssertion from homeassistant.components.husqvarna_automower.const import DOMAIN from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr from .const import TEST_MOWER_ID from tests.common import MockConfigEntry from tests.components.diagnostics import ( get_diagnostics_for_config_entry, get_diagnostics_for_device, ) from tests.typing import ClientSessionGenerator @pytest.mark.freeze_time(datetime.datetime(2024, 2, 29, 11, tzinfo=datetime.UTC)) async def test_entry_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, snapshot: SnapshotAssertion, mock_automower_client: AsyncMock, mock_config_entry: MockConfigEntry, ) -> None: """Test config entry diagnostics.""" mock_config_entry.add_to_hass(hass) await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() result = await get_diagnostics_for_config_entry( hass, hass_client, mock_config_entry ) assert result == snapshot @pytest.mark.freeze_time(datetime.datetime(2024, 2, 29, 11, tzinfo=datetime.UTC)) async def test_device_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, snapshot: SnapshotAssertion, mock_automower_client: AsyncMock, mock_config_entry: MockConfigEntry, device_registry: dr.DeviceRegistry, ) -> None: """Test select platform.""" mock_config_entry.add_to_hass(hass) await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() reg_device = device_registry.async_get_device( identifiers={(DOMAIN, TEST_MOWER_ID)}, ) assert reg_device is not None result = await get_diagnostics_for_device( hass, hass_client, mock_config_entry, reg_device ) assert result == snapshot