Cleanup existing Plugwise tests and test fixtures (#66282)
* Cleanup existing Plugwise tests and test fixtures * More cleanup
This commit is contained in:
parent
e5eba88ecc
commit
bd920aa43d
8 changed files with 310 additions and 377 deletions
|
@ -1,5 +1,7 @@
|
|||
"""Tests for the Plugwise Climate integration."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from plugwise.exceptions import PlugwiseException
|
||||
import pytest
|
||||
|
||||
|
@ -9,55 +11,59 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
from tests.components.plugwise.common import async_init_integration
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_adam_climate_entity_attributes(hass, mock_smile_adam):
|
||||
async def test_adam_climate_entity_attributes(
|
||||
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test creation of adam climate device environment."""
|
||||
entry = await async_init_integration(hass, mock_smile_adam)
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
state = hass.states.get("climate.zone_lisa_wk")
|
||||
attrs = state.attributes
|
||||
|
||||
assert attrs["hvac_modes"] == [HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_AUTO]
|
||||
assert state
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
HVAC_MODE_AUTO,
|
||||
]
|
||||
|
||||
assert "preset_modes" in attrs
|
||||
assert "no_frost" in attrs["preset_modes"]
|
||||
assert "home" in attrs["preset_modes"]
|
||||
assert "preset_modes" in state.attributes
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
|
||||
assert attrs["current_temperature"] == 20.9
|
||||
assert attrs["temperature"] == 21.5
|
||||
|
||||
assert attrs["preset_mode"] == "home"
|
||||
|
||||
assert attrs["supported_features"] == 17
|
||||
assert state.attributes["current_temperature"] == 20.9
|
||||
assert state.attributes["preset_mode"] == "home"
|
||||
assert state.attributes["supported_features"] == 17
|
||||
assert state.attributes["temperature"] == 21.5
|
||||
|
||||
state = hass.states.get("climate.zone_thermostat_jessie")
|
||||
attrs = state.attributes
|
||||
assert state
|
||||
|
||||
assert attrs["hvac_modes"] == [HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_AUTO]
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
HVAC_MODE_AUTO,
|
||||
]
|
||||
|
||||
assert "preset_modes" in attrs
|
||||
assert "no_frost" in attrs["preset_modes"]
|
||||
assert "home" in attrs["preset_modes"]
|
||||
assert "preset_modes" in state.attributes
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
|
||||
assert attrs["current_temperature"] == 17.2
|
||||
assert attrs["temperature"] == 15.0
|
||||
|
||||
assert attrs["preset_mode"] == "asleep"
|
||||
assert state.attributes["current_temperature"] == 17.2
|
||||
assert state.attributes["preset_mode"] == "asleep"
|
||||
assert state.attributes["temperature"] == 15.0
|
||||
|
||||
|
||||
async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
|
||||
async def test_adam_climate_adjust_negative_testing(
|
||||
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test exceptions of climate entities."""
|
||||
mock_smile_adam.set_preset.side_effect = PlugwiseException
|
||||
mock_smile_adam.set_schedule_state.side_effect = PlugwiseException
|
||||
mock_smile_adam.set_temperature.side_effect = PlugwiseException
|
||||
entry = await async_init_integration(hass, mock_smile_adam)
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
|
@ -66,9 +72,6 @@ async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
|
|||
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get("climate.zone_lisa_wk")
|
||||
attrs = state.attributes
|
||||
assert attrs["temperature"] == 21.5
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
|
@ -77,9 +80,6 @@ async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
|
|||
{"entity_id": "climate.zone_thermostat_jessie", "preset_mode": "home"},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get("climate.zone_thermostat_jessie")
|
||||
attrs = state.attributes
|
||||
assert attrs["preset_mode"] == "asleep"
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
|
@ -91,15 +91,12 @@ async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
|
|||
},
|
||||
blocking=True,
|
||||
)
|
||||
state = hass.states.get("climate.zone_thermostat_jessie")
|
||||
attrs = state.attributes
|
||||
|
||||
|
||||
async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam):
|
||||
async def test_adam_climate_entity_climate_changes(
|
||||
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test handling of user requests in adam climate device environment."""
|
||||
entry = await async_init_integration(hass, mock_smile_adam)
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
await hass.services.async_call(
|
||||
"climate",
|
||||
"set_temperature",
|
||||
|
@ -149,36 +146,32 @@ async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam):
|
|||
)
|
||||
|
||||
|
||||
async def test_anna_climate_entity_attributes(hass, mock_smile_anna):
|
||||
async def test_anna_climate_entity_attributes(
|
||||
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test creation of anna climate device environment."""
|
||||
entry = await async_init_integration(hass, mock_smile_anna)
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
state = hass.states.get("climate.anna")
|
||||
attrs = state.attributes
|
||||
|
||||
assert "hvac_modes" in attrs
|
||||
assert attrs["hvac_modes"] == [HVAC_MODE_HEAT, HVAC_MODE_OFF, HVAC_MODE_COOL]
|
||||
|
||||
assert "preset_modes" in attrs
|
||||
assert "no_frost" in attrs["preset_modes"]
|
||||
assert "home" in attrs["preset_modes"]
|
||||
|
||||
assert attrs["current_temperature"] == 19.3
|
||||
assert attrs["temperature"] == 21.0
|
||||
|
||||
assert state
|
||||
assert state.state == HVAC_MODE_HEAT
|
||||
assert attrs["hvac_action"] == "heating"
|
||||
assert attrs["preset_mode"] == "home"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
HVAC_MODE_COOL,
|
||||
]
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
|
||||
assert attrs["supported_features"] == 17
|
||||
assert state.attributes["current_temperature"] == 19.3
|
||||
assert state.attributes["hvac_action"] == "heating"
|
||||
assert state.attributes["preset_mode"] == "home"
|
||||
assert state.attributes["supported_features"] == 17
|
||||
assert state.attributes["temperature"] == 21.0
|
||||
|
||||
|
||||
async def test_anna_climate_entity_climate_changes(hass, mock_smile_anna):
|
||||
async def test_anna_climate_entity_climate_changes(
|
||||
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test handling of user requests in anna climate device environment."""
|
||||
entry = await async_init_integration(hass, mock_smile_anna)
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
await hass.services.async_call(
|
||||
"climate",
|
||||
"set_temperature",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue