"""Tests for the Meater integration.""" from unittest.mock import AsyncMock from syrupy.assertion import SnapshotAssertion from homeassistant.components.meater.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er from . import setup_integration from .const import PROBE_ID from tests.common import MockConfigEntry async def test_device_info( hass: HomeAssistant, snapshot: SnapshotAssertion, mock_meater_client: AsyncMock, mock_config_entry: MockConfigEntry, device_registry: dr.DeviceRegistry, ) -> None: """Test device registry integration.""" await setup_integration(hass, mock_config_entry) device_entry = device_registry.async_get_device(identifiers={(DOMAIN, PROBE_ID)}) assert device_entry is not None assert device_entry == snapshot async def test_load_unload( hass: HomeAssistant, mock_meater_client: AsyncMock, mock_config_entry: MockConfigEntry, entity_registry: er.EntityRegistry, ) -> None: """Test unload of Meater integration.""" await setup_integration(hass, mock_config_entry) assert mock_config_entry.state is ConfigEntryState.LOADED assert ( len( er.async_entries_for_config_entry( entity_registry, mock_config_entry.entry_id ) ) == 8 ) assert ( hass.states.get("sensor.meater_probe_40a72384_ambient_temperature").state != STATE_UNAVAILABLE ) assert await hass.config_entries.async_reload(mock_config_entry.entry_id) assert mock_config_entry.state is ConfigEntryState.LOADED assert ( len( er.async_entries_for_config_entry( entity_registry, mock_config_entry.entry_id ) ) == 8 ) assert ( hass.states.get("sensor.meater_probe_40a72384_ambient_temperature").state != STATE_UNAVAILABLE )