Refactor Sensibo tests to use snapshot (#100775)
This commit is contained in:
parent
8d8c7187d3
commit
28dc17c0b3
4 changed files with 66 additions and 51 deletions
33
tests/components/sensibo/snapshots/test_climate.ambr
Normal file
33
tests/components/sensibo/snapshots/test_climate.ambr
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# serializer version: 1
|
||||||
|
# name: test_climate
|
||||||
|
ReadOnlyDict({
|
||||||
|
'current_humidity': 32.9,
|
||||||
|
'current_temperature': 21.2,
|
||||||
|
'fan_mode': 'high',
|
||||||
|
'fan_modes': list([
|
||||||
|
'quiet',
|
||||||
|
'low',
|
||||||
|
'medium',
|
||||||
|
]),
|
||||||
|
'friendly_name': 'Hallway',
|
||||||
|
'hvac_modes': list([
|
||||||
|
<HVACMode.COOL: 'cool'>,
|
||||||
|
<HVACMode.HEAT: 'heat'>,
|
||||||
|
<HVACMode.DRY: 'dry'>,
|
||||||
|
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||||
|
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||||
|
<HVACMode.OFF: 'off'>,
|
||||||
|
]),
|
||||||
|
'max_temp': 20,
|
||||||
|
'min_temp': 10,
|
||||||
|
'supported_features': <ClimateEntityFeature: 41>,
|
||||||
|
'swing_mode': 'stopped',
|
||||||
|
'swing_modes': list([
|
||||||
|
'stopped',
|
||||||
|
'fixedtop',
|
||||||
|
'fixedmiddletop',
|
||||||
|
]),
|
||||||
|
'target_temp_step': 1,
|
||||||
|
'temperature': 25,
|
||||||
|
})
|
||||||
|
# ---
|
26
tests/components/sensibo/snapshots/test_sensor.ambr
Normal file
26
tests/components/sensibo/snapshots/test_sensor.ambr
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# serializer version: 1
|
||||||
|
# name: test_sensor
|
||||||
|
ReadOnlyDict({
|
||||||
|
'device_class': 'pm25',
|
||||||
|
'friendly_name': 'Kitchen PM2.5',
|
||||||
|
'icon': 'mdi:air-filter',
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'unit_of_measurement': 'µg/m³',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_sensor.1
|
||||||
|
ReadOnlyDict({
|
||||||
|
'device_class': 'temperature',
|
||||||
|
'fanlevel': 'low',
|
||||||
|
'friendly_name': 'Hallway Climate React low temperature threshold',
|
||||||
|
'horizontalswing': 'stopped',
|
||||||
|
'light': 'on',
|
||||||
|
'mode': 'heat',
|
||||||
|
'on': True,
|
||||||
|
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||||
|
'swing': 'stopped',
|
||||||
|
'targettemperature': 21,
|
||||||
|
'temperatureunit': 'c',
|
||||||
|
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||||
|
})
|
||||||
|
# ---
|
|
@ -6,6 +6,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pysensibo.model import SensiboData
|
from pysensibo.model import SensiboData
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
from voluptuous import MultipleInvalid
|
from voluptuous import MultipleInvalid
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
|
@ -80,6 +81,7 @@ async def test_climate(
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
get_data: SensiboData,
|
get_data: SensiboData,
|
||||||
load_int: ConfigEntry,
|
load_int: ConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the Sensibo climate."""
|
"""Test the Sensibo climate."""
|
||||||
|
|
||||||
|
@ -88,36 +90,7 @@ async def test_climate(
|
||||||
state3 = hass.states.get("climate.bedroom")
|
state3 = hass.states.get("climate.bedroom")
|
||||||
|
|
||||||
assert state1.state == "heat"
|
assert state1.state == "heat"
|
||||||
assert state1.attributes == {
|
assert state1.attributes == snapshot
|
||||||
"hvac_modes": [
|
|
||||||
"cool",
|
|
||||||
"heat",
|
|
||||||
"dry",
|
|
||||||
"heat_cool",
|
|
||||||
"fan_only",
|
|
||||||
"off",
|
|
||||||
],
|
|
||||||
"min_temp": 10,
|
|
||||||
"max_temp": 20,
|
|
||||||
"target_temp_step": 1,
|
|
||||||
"fan_modes": [
|
|
||||||
"quiet",
|
|
||||||
"low",
|
|
||||||
"medium",
|
|
||||||
],
|
|
||||||
"swing_modes": [
|
|
||||||
"stopped",
|
|
||||||
"fixedtop",
|
|
||||||
"fixedmiddletop",
|
|
||||||
],
|
|
||||||
"current_temperature": 21.2,
|
|
||||||
"temperature": 25,
|
|
||||||
"current_humidity": 32.9,
|
|
||||||
"fan_mode": "high",
|
|
||||||
"swing_mode": "stopped",
|
|
||||||
"friendly_name": "Hallway",
|
|
||||||
"supported_features": 41,
|
|
||||||
}
|
|
||||||
|
|
||||||
assert state2.state == "off"
|
assert state2.state == "off"
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pysensibo.model import SensiboData
|
from pysensibo.model import SensiboData
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -20,6 +21,7 @@ async def test_sensor(
|
||||||
load_int: ConfigEntry,
|
load_int: ConfigEntry,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
get_data: SensiboData,
|
get_data: SensiboData,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the Sensibo sensor."""
|
"""Test the Sensibo sensor."""
|
||||||
|
|
||||||
|
@ -31,27 +33,8 @@ async def test_sensor(
|
||||||
assert state2.state == "1"
|
assert state2.state == "1"
|
||||||
assert state3.state == "n"
|
assert state3.state == "n"
|
||||||
assert state4.state == "0.0"
|
assert state4.state == "0.0"
|
||||||
assert state2.attributes == {
|
assert state2.attributes == snapshot
|
||||||
"state_class": "measurement",
|
assert state4.attributes == snapshot
|
||||||
"unit_of_measurement": "µg/m³",
|
|
||||||
"device_class": "pm25",
|
|
||||||
"icon": "mdi:air-filter",
|
|
||||||
"friendly_name": "Kitchen PM2.5",
|
|
||||||
}
|
|
||||||
assert state4.attributes == {
|
|
||||||
"device_class": "temperature",
|
|
||||||
"friendly_name": "Hallway Climate React low temperature threshold",
|
|
||||||
"state_class": "measurement",
|
|
||||||
"unit_of_measurement": "°C",
|
|
||||||
"on": True,
|
|
||||||
"targettemperature": 21,
|
|
||||||
"temperatureunit": "c",
|
|
||||||
"mode": "heat",
|
|
||||||
"fanlevel": "low",
|
|
||||||
"swing": "stopped",
|
|
||||||
"horizontalswing": "stopped",
|
|
||||||
"light": "on",
|
|
||||||
}
|
|
||||||
|
|
||||||
monkeypatch.setattr(get_data.parsed["AAZZAAZZ"], "pm25", 2)
|
monkeypatch.setattr(get_data.parsed["AAZZAAZZ"], "pm25", 2)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue