diff --git a/tests/components/balboa/snapshots/test_binary_sensor.ambr b/tests/components/balboa/snapshots/test_binary_sensor.ambr new file mode 100644 index 00000000000..c37c8a20d4b --- /dev/null +++ b/tests/components/balboa/snapshots/test_binary_sensor.ambr @@ -0,0 +1,142 @@ +# serializer version: 1 +# name: test_binary_sensors[binary_sensor.fakespa_circulation_pump-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.fakespa_circulation_pump', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Circulation pump', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'circ_pump', + 'unique_id': 'FakeSpa-Circ Pump-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[binary_sensor.fakespa_circulation_pump-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'running', + 'friendly_name': 'FakeSpa Circulation pump', + }), + 'context': , + 'entity_id': 'binary_sensor.fakespa_circulation_pump', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_1-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.fakespa_filter_cycle_1', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Filter cycle 1', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'filter_1', + 'unique_id': 'FakeSpa-Filter1-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_1-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'running', + 'friendly_name': 'FakeSpa Filter cycle 1', + }), + 'context': , + 'entity_id': 'binary_sensor.fakespa_filter_cycle_1', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_2-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.fakespa_filter_cycle_2', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Filter cycle 2', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'filter_2', + 'unique_id': 'FakeSpa-Filter2-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_2-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'running', + 'friendly_name': 'FakeSpa Filter cycle 2', + }), + 'context': , + 'entity_id': 'binary_sensor.fakespa_filter_cycle_2', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/balboa/snapshots/test_climate.ambr b/tests/components/balboa/snapshots/test_climate.ambr new file mode 100644 index 00000000000..8e1d8f5e5e7 --- /dev/null +++ b/tests/components/balboa/snapshots/test_climate.ambr @@ -0,0 +1,74 @@ +# serializer version: 1 +# name: test_climate[climate.fakespa-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 40.0, + 'min_temp': 10.0, + 'preset_modes': list([ + 'ready', + 'rest', + ]), + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'climate', + 'entity_category': None, + 'entity_id': 'climate.fakespa', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': 'mdi:hot-tub', + 'original_name': None, + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': , + 'translation_key': 'balboa', + 'unique_id': 'FakeSpa-Climate-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_climate[climate.fakespa-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 10.0, + 'friendly_name': 'FakeSpa', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'icon': 'mdi:hot-tub', + 'max_temp': 40.0, + 'min_temp': 10.0, + 'preset_mode': 'ready', + 'preset_modes': list([ + 'ready', + 'rest', + ]), + 'supported_features': , + 'temperature': 40.0, + }), + 'context': , + 'entity_id': 'climate.fakespa', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'heat', + }) +# --- diff --git a/tests/components/balboa/snapshots/test_fan.ambr b/tests/components/balboa/snapshots/test_fan.ambr new file mode 100644 index 00000000000..2b87a961906 --- /dev/null +++ b/tests/components/balboa/snapshots/test_fan.ambr @@ -0,0 +1,54 @@ +# serializer version: 1 +# name: test_fan[fan.fakespa_pump_1-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'preset_modes': None, + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'fan', + 'entity_category': None, + 'entity_id': 'fan.fakespa_pump_1', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Pump 1', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': , + 'translation_key': 'pump', + 'unique_id': 'FakeSpa-Pump 1-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_fan[fan.fakespa_pump_1-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'FakeSpa Pump 1', + 'percentage': 0, + 'percentage_step': 50.0, + 'preset_mode': None, + 'preset_modes': None, + 'supported_features': , + }), + 'context': , + 'entity_id': 'fan.fakespa_pump_1', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/balboa/snapshots/test_light.ambr b/tests/components/balboa/snapshots/test_light.ambr new file mode 100644 index 00000000000..31777744740 --- /dev/null +++ b/tests/components/balboa/snapshots/test_light.ambr @@ -0,0 +1,56 @@ +# serializer version: 1 +# name: test_lights[light.fakespa_light-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'supported_color_modes': list([ + , + ]), + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'light', + 'entity_category': None, + 'entity_id': 'light.fakespa_light', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Light', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'only_light', + 'unique_id': 'FakeSpa-Light-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_lights[light.fakespa_light-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'color_mode': None, + 'friendly_name': 'FakeSpa Light', + 'supported_color_modes': list([ + , + ]), + 'supported_features': , + }), + 'context': , + 'entity_id': 'light.fakespa_light', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- diff --git a/tests/components/balboa/snapshots/test_select.ambr b/tests/components/balboa/snapshots/test_select.ambr new file mode 100644 index 00000000000..c1ea32a3628 --- /dev/null +++ b/tests/components/balboa/snapshots/test_select.ambr @@ -0,0 +1,57 @@ +# serializer version: 1 +# name: test_selects[select.fakespa_temperature_range-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'low', + 'high', + ]), + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'select', + 'entity_category': None, + 'entity_id': 'select.fakespa_temperature_range', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': 'mdi:thermometer-lines', + 'original_name': 'Temperature range', + 'platform': 'balboa', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'temperature_range', + 'unique_id': 'FakeSpa-TempHiLow-c0ffee', + 'unit_of_measurement': None, + }) +# --- +# name: test_selects[select.fakespa_temperature_range-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'FakeSpa Temperature range', + 'icon': 'mdi:thermometer-lines', + 'options': list([ + 'low', + 'high', + ]), + }), + 'context': , + 'entity_id': 'select.fakespa_temperature_range', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'low', + }) +# --- diff --git a/tests/components/balboa/test_binary_sensor.py b/tests/components/balboa/test_binary_sensor.py index bcce2b96a0b..5990c73bb68 100644 --- a/tests/components/balboa/test_binary_sensor.py +++ b/tests/components/balboa/test_binary_sensor.py @@ -1,17 +1,35 @@ -"""Tests of the climate entity of the balboa integration.""" +"""Tests of the binary sensors of the balboa integration.""" from __future__ import annotations -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch -from homeassistant.const import STATE_OFF, STATE_ON +from syrupy import SnapshotAssertion + +from homeassistant.const import STATE_OFF, STATE_ON, Platform from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er -from tests.common import MockConfigEntry +from . import init_integration + +from tests.common import MockConfigEntry, snapshot_platform ENTITY_BINARY_SENSOR = "binary_sensor.fakespa_" +async def test_binary_sensors( + hass: HomeAssistant, + client: MagicMock, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test spa binary sensors.""" + with patch("homeassistant.components.balboa.PLATFORMS", [Platform.BINARY_SENSOR]): + entry = await init_integration(hass) + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + async def test_filters( hass: HomeAssistant, client: MagicMock, integration: MockConfigEntry ) -> None: diff --git a/tests/components/balboa/test_climate.py b/tests/components/balboa/test_climate.py index c75244ecb94..c877f2858cd 100644 --- a/tests/components/balboa/test_climate.py +++ b/tests/components/balboa/test_climate.py @@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patch from pybalboa import SpaControl from pybalboa.enums import HeatMode, OffLowMediumHighState import pytest +from syrupy import SnapshotAssertion from homeassistant.components.climate import ( ATTR_FAN_MODE, @@ -25,13 +26,14 @@ from homeassistant.components.climate import ( HVACAction, HVACMode, ) -from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature +from homeassistant.const import ATTR_TEMPERATURE, Platform, UnitOfTemperature from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import ServiceValidationError +from homeassistant.helpers import entity_registry as er from . import client_update, init_integration -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.climate import common HVAC_SETTINGS = [ @@ -43,25 +45,17 @@ HVAC_SETTINGS = [ ENTITY_CLIMATE = "climate.fakespa" -async def test_spa_defaults( - hass: HomeAssistant, client: MagicMock, integration: MockConfigEntry +async def test_climate( + hass: HomeAssistant, + client: MagicMock, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, ) -> None: - """Test supported features flags.""" - state = hass.states.get(ENTITY_CLIMATE) + """Test spa climate.""" + with patch("homeassistant.components.balboa.PLATFORMS", [Platform.CLIMATE]): + entry = await init_integration(hass) - assert state - assert ( - state.attributes["supported_features"] - == ClimateEntityFeature.TARGET_TEMPERATURE - | ClimateEntityFeature.PRESET_MODE - | ClimateEntityFeature.TURN_OFF - | ClimateEntityFeature.TURN_ON - ) - assert state.state == HVACMode.HEAT - assert state.attributes[ATTR_MIN_TEMP] == 10.0 - assert state.attributes[ATTR_MAX_TEMP] == 40.0 - assert state.attributes[ATTR_PRESET_MODE] == "ready" - assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) async def test_spa_defaults_fake_tscale( diff --git a/tests/components/balboa/test_fan.py b/tests/components/balboa/test_fan.py index 878a14784f7..3eacb0d08c0 100644 --- a/tests/components/balboa/test_fan.py +++ b/tests/components/balboa/test_fan.py @@ -2,24 +2,27 @@ from __future__ import annotations -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch from pybalboa import SpaControl from pybalboa.enums import OffLowHighState, UnknownState import pytest +from syrupy import SnapshotAssertion from homeassistant.components.fan import ATTR_PERCENTAGE -from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN +from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from . import client_update, init_integration +from tests.common import snapshot_platform from tests.components.fan import common ENTITY_FAN = "fan.fakespa_pump_1" -@pytest.fixture +@pytest.fixture(autouse=True) def mock_pump(client: MagicMock): """Return a mock pump.""" pump = MagicMock(SpaControl) @@ -28,6 +31,7 @@ def mock_pump(client: MagicMock): pump.state = state pump.client = client + pump.name = "Pump 1" pump.index = 0 pump.state = OffLowHighState.OFF pump.set_state = set_state @@ -37,6 +41,19 @@ def mock_pump(client: MagicMock): return pump +async def test_fan( + hass: HomeAssistant, + client: MagicMock, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test spa fans.""" + with patch("homeassistant.components.balboa.PLATFORMS", [Platform.FAN]): + entry = await init_integration(hass) + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + async def test_pump(hass: HomeAssistant, client: MagicMock, mock_pump) -> None: """Test spa pump.""" await init_integration(hass) diff --git a/tests/components/balboa/test_light.py b/tests/components/balboa/test_light.py index da969a7e2d8..01469416da5 100644 --- a/tests/components/balboa/test_light.py +++ b/tests/components/balboa/test_light.py @@ -2,23 +2,26 @@ from __future__ import annotations -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch from pybalboa import SpaControl from pybalboa.enums import OffOnState, UnknownState import pytest +from syrupy import SnapshotAssertion -from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN +from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from . import client_update, init_integration +from tests.common import snapshot_platform from tests.components.light import common ENTITY_LIGHT = "light.fakespa_light" -@pytest.fixture +@pytest.fixture(autouse=True) def mock_light(client: MagicMock): """Return a mock light.""" light = MagicMock(SpaControl) @@ -26,6 +29,7 @@ def mock_light(client: MagicMock): async def set_state(state: OffOnState): light.state = state + light.name = "Light" light.client = client light.index = 0 light.state = OffOnState.OFF @@ -36,6 +40,19 @@ def mock_light(client: MagicMock): return light +async def test_lights( + hass: HomeAssistant, + client: MagicMock, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test spa light.""" + with patch("homeassistant.components.balboa.PLATFORMS", [Platform.LIGHT]): + entry = await init_integration(hass) + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + async def test_light(hass: HomeAssistant, client: MagicMock, mock_light) -> None: """Test spa light.""" await init_integration(hass) diff --git a/tests/components/balboa/test_select.py b/tests/components/balboa/test_select.py index bd79f024817..da57ee8f22e 100644 --- a/tests/components/balboa/test_select.py +++ b/tests/components/balboa/test_select.py @@ -2,26 +2,30 @@ from __future__ import annotations -from unittest.mock import MagicMock, call +from unittest.mock import MagicMock, call, patch from pybalboa import SpaControl from pybalboa.enums import LowHighRange import pytest +from syrupy import SnapshotAssertion from homeassistant.components.select import ( ATTR_OPTION, DOMAIN as SELECT_DOMAIN, SERVICE_SELECT_OPTION, ) -from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from . import client_update, init_integration +from tests.common import snapshot_platform + ENTITY_SELECT = "select.fakespa_temperature_range" -@pytest.fixture +@pytest.fixture(autouse=True) def mock_select(client: MagicMock): """Return a mock switch.""" select = MagicMock(SpaControl) @@ -36,6 +40,19 @@ def mock_select(client: MagicMock): return select +async def test_selects( + hass: HomeAssistant, + client: MagicMock, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test spa climate.""" + with patch("homeassistant.components.balboa.PLATFORMS", [Platform.SELECT]): + entry = await init_integration(hass) + + await snapshot_platform(hass, entity_registry, snapshot, entry.entry_id) + + async def test_select(hass: HomeAssistant, client: MagicMock, mock_select) -> None: """Test spa temperature range select.""" await init_integration(hass)