mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add snapshot tests to Balboa (#117620)
This commit is contained in:
parent
081bf1cc39
commit
0b8a5ac9ad
142
tests/components/balboa/snapshots/test_binary_sensor.ambr
Normal file
142
tests/components/balboa/snapshots/test_binary_sensor.ambr
Normal file
@ -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': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'binary_sensor.fakespa_circulation_pump',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_1-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'binary_sensor.fakespa_filter_cycle_1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[binary_sensor.fakespa_filter_cycle_2-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'binary_sensor.fakespa_filter_cycle_2',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
74
tests/components/balboa/snapshots/test_climate.ambr
Normal file
74
tests/components/balboa/snapshots/test_climate.ambr
Normal file
@ -0,0 +1,74 @@
|
||||
# serializer version: 1
|
||||
# name: test_climate[climate.fakespa-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.OFF: 'off'>,
|
||||
]),
|
||||
'max_temp': 40.0,
|
||||
'min_temp': 10.0,
|
||||
'preset_modes': list([
|
||||
'ready',
|
||||
'rest',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.fakespa',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ClimateEntityFeature: 401>,
|
||||
'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': <HVACAction.IDLE: 'idle'>,
|
||||
'hvac_modes': list([
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.OFF: 'off'>,
|
||||
]),
|
||||
'icon': 'mdi:hot-tub',
|
||||
'max_temp': 40.0,
|
||||
'min_temp': 10.0,
|
||||
'preset_mode': 'ready',
|
||||
'preset_modes': list([
|
||||
'ready',
|
||||
'rest',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 401>,
|
||||
'temperature': 40.0,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.fakespa',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'heat',
|
||||
})
|
||||
# ---
|
54
tests/components/balboa/snapshots/test_fan.ambr
Normal file
54
tests/components/balboa/snapshots/test_fan.ambr
Normal file
@ -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': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'fan',
|
||||
'entity_category': None,
|
||||
'entity_id': 'fan.fakespa_pump_1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <FanEntityFeature: 1>,
|
||||
'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': <FanEntityFeature: 1>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'fan.fakespa_pump_1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
56
tests/components/balboa/snapshots/test_light.ambr
Normal file
56
tests/components/balboa/snapshots/test_light.ambr
Normal file
@ -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([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'light',
|
||||
'entity_category': None,
|
||||
'entity_id': 'light.fakespa_light',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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([
|
||||
<ColorMode.ONOFF: 'onoff'>,
|
||||
]),
|
||||
'supported_features': <LightEntityFeature: 0>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'light.fakespa_light',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
57
tests/components/balboa/snapshots/test_select.ambr
Normal file
57
tests/components/balboa/snapshots/test_select.ambr
Normal file
@ -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': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'select',
|
||||
'entity_category': None,
|
||||
'entity_id': 'select.fakespa_temperature_range',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'select.fakespa_temperature_range',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'low',
|
||||
})
|
||||
# ---
|
@ -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:
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user