Rename VersatileThermostat with BaseThermostat. Tests ok

This commit is contained in:
Jean-Marc Collin
2023-10-22 16:54:38 +00:00
parent c9671a5c58
commit ae799adbd4
20 changed files with 2779 additions and 2714 deletions

View File

@@ -1,6 +1,6 @@
{ {
"[python]": { "[python]": {
"editor.defaultFormatter": "ms-python.black-formatter" "editor.defaultFormatter": "mikoz.black-py"
}, },
"python.linting.pylintEnabled": true, "python.linting.pylintEnabled": true,
"python.linting.enabled": true, "python.linting.enabled": true,

View File

@@ -8,7 +8,7 @@ import logging
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .climate import VersatileThermostat from .base_thermostat import BaseThermostat
from .const import DOMAIN, PLATFORMS from .const import DOMAIN, PLATFORMS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType from homeassistant.helpers.device_registry import DeviceInfo, DeviceEntryType
from homeassistant.helpers.event import async_track_state_change_event, async_call_later from homeassistant.helpers.event import async_track_state_change_event, async_call_later
from .climate import VersatileThermostat from .base_thermostat import BaseThermostat
from .const import DOMAIN, DEVICE_MANUFACTURER from .const import DOMAIN, DEVICE_MANUFACTURER
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@@ -17,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
class VersatileThermostatBaseEntity(Entity): class VersatileThermostatBaseEntity(Entity):
"""A base class for all entities""" """A base class for all entities"""
_my_climate: VersatileThermostat _my_climate: BaseThermostat
hass: HomeAssistant hass: HomeAssistant
_config_id: str _config_id: str
_device_name: str _device_name: str
@@ -37,7 +37,7 @@ class VersatileThermostatBaseEntity(Entity):
return False return False
@property @property
def my_climate(self) -> VersatileThermostat | None: def my_climate(self) -> BaseThermostat | None:
"""Returns my climate if found""" """Returns my climate if found"""
if not self._my_climate: if not self._my_climate:
self._my_climate = self.find_my_versatile_thermostat() self._my_climate = self.find_my_versatile_thermostat()
@@ -54,7 +54,7 @@ class VersatileThermostatBaseEntity(Entity):
model=DOMAIN, model=DOMAIN,
) )
def find_my_versatile_thermostat(self) -> VersatileThermostat: def find_my_versatile_thermostat(self) -> BaseThermostat:
"""Find the underlying climate entity""" """Find the underlying climate entity"""
try: try:
component: EntityComponent[ClimateEntity] = self.hass.data[CLIMATE_DOMAIN] component: EntityComponent[ClimateEntity] = self.hass.data[CLIMATE_DOMAIN]

View File

@@ -0,0 +1,11 @@
""" A climate over switch classe """
from homeassistant.core import HomeAssistant
from .base_thermostat import BaseThermostat
class ThermostatOverClimate(BaseThermostat):
"""Representation of a base class for a Versatile Thermostat over a climate"""
def __init__(self, hass: HomeAssistant, unique_id, name, entry_infos) -> None:
"""Initialize the thermostat over switch."""
super().__init__(hass, unique_id, name, entry_infos)

View File

@@ -0,0 +1,13 @@
""" A climate over switch classe """
from homeassistant.core import HomeAssistant
from .base_thermostat import BaseThermostat
class ThermostatOverSwitch(BaseThermostat):
"""Representation of a base class for a Versatile Thermostat over a switch."""
def __init__(self, hass: HomeAssistant, unique_id, name, entry_infos) -> None:
"""Initialize the thermostat over switch."""
super().__init__(hass, unique_id, name, entry_infos)

View File

@@ -0,0 +1,11 @@
""" A climate over switch classe """
from homeassistant.core import HomeAssistant
from .base_thermostat import BaseThermostat
class ThermostatOverValve(BaseThermostat):
"""Representation of a class for a Versatile Thermostat over a Valve"""
def __init__(self, hass: HomeAssistant, unique_id, name, entry_infos) -> None:
"""Initialize the thermostat over switch."""
super().__init__(hass, unique_id, name, entry_infos)

View File

@@ -20,7 +20,7 @@ from homeassistant.components.climate import (
from pytest_homeassistant_custom_component.common import MockConfigEntry from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.versatile_thermostat.climate import VersatileThermostat from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
from custom_components.versatile_thermostat.const import * # pylint: disable=wildcard-import, unused-wildcard-import from custom_components.versatile_thermostat.const import * # pylint: disable=wildcard-import, unused-wildcard-import
from custom_components.versatile_thermostat.underlyings import * # pylint: disable=wildcard-import, unused-wildcard-import from custom_components.versatile_thermostat.underlyings import * # pylint: disable=wildcard-import, unused-wildcard-import
@@ -219,10 +219,10 @@ class MagicMockClimate(MagicMock):
async def create_thermostat( async def create_thermostat(
hass: HomeAssistant, entry: MockConfigEntry, entity_id: str hass: HomeAssistant, entry: MockConfigEntry, entity_id: str
) -> VersatileThermostat: ) -> BaseThermostat:
"""Creates and return a TPI Thermostat""" """Creates and return a TPI Thermostat"""
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
): ):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
@@ -248,7 +248,7 @@ def search_entity(hass: HomeAssistant, entity_id, domain) -> Entity:
async def send_temperature_change_event( async def send_temperature_change_event(
entity: VersatileThermostat, new_temp, date, sleep=True entity: BaseThermostat, new_temp, date, sleep=True
): ):
"""Sending a new temperature event simulating a change on temperature sensor""" """Sending a new temperature event simulating a change on temperature sensor"""
_LOGGER.info( _LOGGER.info(
@@ -274,7 +274,7 @@ async def send_temperature_change_event(
async def send_ext_temperature_change_event( async def send_ext_temperature_change_event(
entity: VersatileThermostat, new_temp, date, sleep=True entity: BaseThermostat, new_temp, date, sleep=True
): ):
"""Sending a new external temperature event simulating a change on temperature sensor""" """Sending a new external temperature event simulating a change on temperature sensor"""
_LOGGER.info( _LOGGER.info(
@@ -300,7 +300,7 @@ async def send_ext_temperature_change_event(
async def send_power_change_event( async def send_power_change_event(
entity: VersatileThermostat, new_power, date, sleep=True entity: BaseThermostat, new_power, date, sleep=True
): ):
"""Sending a new power event simulating a change on power sensor""" """Sending a new power event simulating a change on power sensor"""
_LOGGER.info( _LOGGER.info(
@@ -326,7 +326,7 @@ async def send_power_change_event(
async def send_max_power_change_event( async def send_max_power_change_event(
entity: VersatileThermostat, new_power_max, date, sleep=True entity: BaseThermostat, new_power_max, date, sleep=True
): ):
"""Sending a new power max event simulating a change on power max sensor""" """Sending a new power max event simulating a change on power max sensor"""
_LOGGER.info( _LOGGER.info(
@@ -352,7 +352,7 @@ async def send_max_power_change_event(
async def send_window_change_event( async def send_window_change_event(
entity: VersatileThermostat, new_state: bool, old_state: bool, date, sleep=True entity: BaseThermostat, new_state: bool, old_state: bool, date, sleep=True
): ):
"""Sending a new window event simulating a change on the window state""" """Sending a new window event simulating a change on the window state"""
_LOGGER.info( _LOGGER.info(
@@ -386,7 +386,7 @@ async def send_window_change_event(
async def send_motion_change_event( async def send_motion_change_event(
entity: VersatileThermostat, new_state: bool, old_state: bool, date, sleep=True entity: BaseThermostat, new_state: bool, old_state: bool, date, sleep=True
): ):
"""Sending a new motion event simulating a change on the window state""" """Sending a new motion event simulating a change on the window state"""
_LOGGER.info( _LOGGER.info(
@@ -420,7 +420,7 @@ async def send_motion_change_event(
async def send_presence_change_event( async def send_presence_change_event(
entity: VersatileThermostat, new_state: bool, old_state: bool, date, sleep=True entity: BaseThermostat, new_state: bool, old_state: bool, date, sleep=True
): ):
"""Sending a new presence event simulating a change on the window state""" """Sending a new presence event simulating a change on the window state"""
_LOGGER.info( _LOGGER.info(
@@ -460,7 +460,7 @@ def get_tz(hass: HomeAssistant):
async def send_climate_change_event( async def send_climate_change_event(
entity: VersatileThermostat, entity: BaseThermostat,
new_hvac_mode: HVACMode, new_hvac_mode: HVACMode,
old_hvac_mode: HVACMode, old_hvac_mode: HVACMode,
new_hvac_action: HVACAction, new_hvac_action: HVACAction,
@@ -503,7 +503,7 @@ async def send_climate_change_event(
return ret return ret
async def send_climate_change_event_with_temperature( async def send_climate_change_event_with_temperature(
entity: VersatileThermostat, entity: BaseThermostat,
new_hvac_mode: HVACMode, new_hvac_mode: HVACMode,
old_hvac_mode: HVACMode, old_hvac_mode: HVACMode,
new_hvac_action: HVACAction, new_hvac_action: HVACAction,
@@ -548,7 +548,7 @@ async def send_climate_change_event_with_temperature(
return ret return ret
def cancel_switchs_cycles(entity: VersatileThermostat): def cancel_switchs_cycles(entity: BaseThermostat):
"""This method will cancel all running cycle on all underlying switch entity""" """This method will cancel all running cycle on all underlying switch entity"""
if entity._is_over_climate: if entity._is_over_climate:
return return

View File

@@ -26,9 +26,7 @@ from custom_components.versatile_thermostat.config_flow import (
VersatileThermostatBaseConfigFlow, VersatileThermostatBaseConfigFlow,
) )
from custom_components.versatile_thermostat.climate import ( from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
VersatileThermostat,
)
pytest_plugins = "pytest_homeassistant_custom_component" # pylint: disable=invalid-name pytest_plugins = "pytest_homeassistant_custom_component" # pylint: disable=invalid-name
@@ -84,7 +82,7 @@ def skip_hass_states_get_fixture():
def skip_control_heating_fixture(): def skip_control_heating_fixture():
"""Skip the control_heating of VersatileThermostat""" """Skip the control_heating of VersatileThermostat"""
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
yield yield
@@ -107,6 +105,6 @@ def skip_hass_states_is_state_fixture():
@pytest.fixture(name="skip_send_event") @pytest.fixture(name="skip_send_event")
def skip_send_event_fixture(): def skip_send_event_fixture():
"""Skip the send_event in VersatileThermostat""" """Skip the send_event in BaseThermostat"""
with patch.object(VersatileThermostat, "send_event"): with patch.object(BaseThermostat, "send_event"):
yield yield

View File

@@ -1,3 +1,5 @@
# pylint: disable=wildcard-import, unused-wildcard-import, unused-argument, line-too-long
""" Test the normal start of a Thermostat """ """ Test the normal start of a Thermostat """
from unittest.mock import patch from unittest.mock import patch
from datetime import timedelta, datetime from datetime import timedelta, datetime
@@ -9,7 +11,7 @@ from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from pytest_homeassistant_custom_component.common import MockConfigEntry from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.versatile_thermostat.climate import VersatileThermostat from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
from custom_components.versatile_thermostat.binary_sensor import ( from custom_components.versatile_thermostat.binary_sensor import (
SecurityBinarySensor, SecurityBinarySensor,
OverpoweringBinarySensor, OverpoweringBinarySensor,
@@ -18,7 +20,7 @@ from custom_components.versatile_thermostat.binary_sensor import (
PresenceBinarySensor, PresenceBinarySensor,
) )
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import from .commons import *
@pytest.mark.parametrize("expected_lingering_tasks", [True]) @pytest.mark.parametrize("expected_lingering_tasks", [True])
@@ -60,7 +62,7 @@ async def test_security_binary_sensors(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat (
hass, entry, "climate.theoverswitchmockname" hass, entry, "climate.theoverswitchmockname"
) )
assert entity assert entity
@@ -141,7 +143,7 @@ async def test_overpowering_binary_sensors(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat(
hass, entry, "climate.theoverswitchmockname" hass, entry, "climate.theoverswitchmockname"
) )
assert entity assert entity
@@ -223,7 +225,7 @@ async def test_window_binary_sensors(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat(
hass, entry, "climate.theoverswitchmockname" hass, entry, "climate.theoverswitchmockname"
) )
assert entity assert entity
@@ -311,7 +313,7 @@ async def test_motion_binary_sensors(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat(
hass, entry, "climate.theoverswitchmockname" hass, entry, "climate.theoverswitchmockname"
) )
assert entity assert entity
@@ -401,7 +403,7 @@ async def test_presence_binary_sensors(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat(
hass, entry, "climate.theoverswitchmockname" hass, entry, "climate.theoverswitchmockname"
) )
assert entity assert entity
@@ -483,7 +485,7 @@ async def test_binary_sensors_over_climate_minimal(
}, },
) )
entity: VersatileThermostat = await create_thermostat( entity: BaseThermostat = await create_thermostat(
hass, entry, "climate.theoverclimatemockname" hass, entry, "climate.theoverclimatemockname"
) )
assert entity assert entity

View File

@@ -245,7 +245,7 @@ async def test_bug_66(
# Open the window and let the thermostat shut down # Open the window and let the thermostat shut down
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -273,7 +273,7 @@ async def test_bug_66(
# Close the window but too shortly # Close the window but too shortly
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -296,7 +296,7 @@ async def test_bug_66(
# Reopen immediatly with sufficient time # Reopen immediatly with sufficient time
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -319,7 +319,7 @@ async def test_bug_66(
# Close the window but with sufficient time this time # Close the window but with sufficient time this time
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -366,7 +366,7 @@ async def test_bug_82(
fake_underlying_climate = MockUnavailableClimate(hass, "mockUniqueId", "MockClimateName", {}) fake_underlying_climate = MockUnavailableClimate(hass, "mockUniqueId", "MockClimateName", {})
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate", "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate",
return_value=fake_underlying_climate, return_value=fake_underlying_climate,
@@ -431,7 +431,7 @@ async def test_bug_82(
# 2. activate security feature when date is expired # 2. activate security feature when date is expired
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on: ) as mock_heater_on:
@@ -468,7 +468,7 @@ async def test_bug_101(
fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {}, HVACMode.HEAT) fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {}, HVACMode.HEAT)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate", "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate",
return_value=fake_underlying_climate, return_value=fake_underlying_climate,

View File

@@ -64,7 +64,7 @@ async def test_movement_management_time_not_enough(
# start heating, in boost mode, when someone is present. We block the control_heating to avoid running a cycle # start heating, in boost mode, when someone is present. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
await entity.async_set_hvac_mode(HVACMode.HEAT) await entity.async_set_hvac_mode(HVACMode.HEAT)
await entity.async_set_preset_mode(PRESET_ACTIVITY) await entity.async_set_preset_mode(PRESET_ACTIVITY)
@@ -85,7 +85,7 @@ async def test_movement_management_time_not_enough(
# starts detecting motion with time not enough # starts detecting motion with time not enough
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -118,7 +118,7 @@ async def test_movement_management_time_not_enough(
# starts detecting motion with time enough this time # starts detecting motion with time enough this time
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -144,7 +144,7 @@ async def test_movement_management_time_not_enough(
# stop detecting motion with off delay too low # stop detecting motion with off delay too low
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -176,7 +176,7 @@ async def test_movement_management_time_not_enough(
# stop detecting motion with off delay enough long # stop detecting motion with off delay enough long
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -261,7 +261,7 @@ async def test_movement_management_time_enough_and_presence(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
await entity.async_set_hvac_mode(HVACMode.HEAT) await entity.async_set_hvac_mode(HVACMode.HEAT)
await entity.async_set_preset_mode(PRESET_ACTIVITY) await entity.async_set_preset_mode(PRESET_ACTIVITY)
@@ -282,7 +282,7 @@ async def test_movement_management_time_enough_and_presence(
# starts detecting motion # starts detecting motion
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -311,7 +311,7 @@ async def test_movement_management_time_enough_and_presence(
# stop detecting motion with confirmation of stop # stop detecting motion with confirmation of stop
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -393,7 +393,7 @@ async def test_movement_management_time_enoughand_not_presence(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
await entity.async_set_hvac_mode(HVACMode.HEAT) await entity.async_set_hvac_mode(HVACMode.HEAT)
await entity.async_set_preset_mode(PRESET_ACTIVITY) await entity.async_set_preset_mode(PRESET_ACTIVITY)
@@ -414,7 +414,7 @@ async def test_movement_management_time_enoughand_not_presence(
# starts detecting motion # starts detecting motion
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -443,7 +443,7 @@ async def test_movement_management_time_enoughand_not_presence(
# stop detecting motion with confirmation of stop # stop detecting motion with confirmation of stop
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -527,7 +527,7 @@ async def test_movement_management_with_stop_during_condition(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
await entity.async_set_hvac_mode(HVACMode.HEAT) await entity.async_set_hvac_mode(HVACMode.HEAT)
await entity.async_set_preset_mode(PRESET_ACTIVITY) await entity.async_set_preset_mode(PRESET_ACTIVITY)
@@ -548,7 +548,7 @@ async def test_movement_management_with_stop_during_condition(
# starts detecting motion # starts detecting motion
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(

View File

@@ -58,7 +58,7 @@ async def test_one_switch_cycle(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
): ):
await entity.async_set_hvac_mode(HVACMode.HEAT) await entity.async_set_hvac_mode(HVACMode.HEAT)
await entity.async_set_preset_mode(PRESET_BOOST) await entity.async_set_preset_mode(PRESET_BOOST)
@@ -82,7 +82,7 @@ async def test_one_switch_cycle(
# Set temperature to a low level # Set temperature to a low level
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -117,7 +117,7 @@ async def test_one_switch_cycle(
# Set a temperature at middle level # Set a temperature at middle level
event_timestamp = now - timedelta(minutes=4) event_timestamp = now - timedelta(minutes=4)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -139,7 +139,7 @@ async def test_one_switch_cycle(
# Set another temperature at middle level # Set another temperature at middle level
event_timestamp = now - timedelta(minutes=3) event_timestamp = now - timedelta(minutes=3)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -172,7 +172,7 @@ async def test_one_switch_cycle(
# Simulate the end of heater on cycle # Simulate the end of heater on cycle
event_timestamp = now - timedelta(minutes=3) event_timestamp = now - timedelta(minutes=3)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -195,7 +195,7 @@ async def test_one_switch_cycle(
# Simulate the start of heater on cycle # Simulate the start of heater on cycle
event_timestamp = now - timedelta(minutes=3) event_timestamp = now - timedelta(minutes=3)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -269,7 +269,7 @@ async def test_multiple_switchs(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.set_hvac_mode"
) as mock_underlying_set_hvac_mode: ) as mock_underlying_set_hvac_mode:
@@ -297,7 +297,7 @@ async def test_multiple_switchs(
# Set temperature to a low level # Set temperature to a low level
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -335,7 +335,7 @@ async def test_multiple_switchs(
# Set a temperature at middle level # Set a temperature at middle level
event_timestamp = now - timedelta(minutes=4) event_timestamp = now - timedelta(minutes=4)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -405,7 +405,7 @@ async def test_multiple_climates(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
) as mock_underlying_set_hvac_mode: ) as mock_underlying_set_hvac_mode:
@@ -431,7 +431,7 @@ async def test_multiple_climates(
# Stop heating, in boost mode. We block the control_heating to avoid running a cycle # Stop heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
) as mock_underlying_set_hvac_mode: ) as mock_underlying_set_hvac_mode:
@@ -505,7 +505,7 @@ async def test_multiple_climates_underlying_changes(
# start heating, in boost mode. We block the control_heating to avoid running a cycle # start heating, in boost mode. We block the control_heating to avoid running a cycle
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
) as mock_underlying_set_hvac_mode: ) as mock_underlying_set_hvac_mode:
@@ -531,7 +531,7 @@ async def test_multiple_climates_underlying_changes(
# Stop heating on one underlying climate # Stop heating on one underlying climate
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
) as mock_underlying_set_hvac_mode: ) as mock_underlying_set_hvac_mode:
@@ -558,7 +558,7 @@ async def test_multiple_climates_underlying_changes(
# Start heating on one underlying climate # Start heating on one underlying climate
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat._async_control_heating" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat._async_control_heating"
), patch( ), patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode" "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.set_hvac_mode"
) as mock_underlying_set_hvac_mode, patch( ) as mock_underlying_set_hvac_mode, patch(

View File

@@ -81,7 +81,7 @@ async def test_power_management_hvac_off(
# Send power max mesurement too low but HVACMode is off # Send power max mesurement too low but HVACMode is off
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -162,7 +162,7 @@ async def test_power_management_hvac_on(hass: HomeAssistant, skip_hass_states_is
# Send power max mesurement too low and HVACMode is on # Send power max mesurement too low and HVACMode is on
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -196,7 +196,7 @@ async def test_power_management_hvac_on(hass: HomeAssistant, skip_hass_states_is
# Send power mesurement low to unseet power preset # Send power mesurement low to unseet power preset
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -282,7 +282,7 @@ async def test_power_management_energy_over_switch(
# set temperature to 15 so that on_percent will be set # set temperature to 15 so that on_percent will be set
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -311,7 +311,7 @@ async def test_power_management_energy_over_switch(
# change temperature to a higher value # change temperature to a higher value
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -333,7 +333,7 @@ async def test_power_management_energy_over_switch(
# change temperature to a much higher value so that heater will be shut down # change temperature to a much higher value so that heater will be shut down
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(

View File

@@ -87,7 +87,7 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
# 2. activate security feature when date is expired # 2. activate security feature when date is expired
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on: ) as mock_heater_on:
@@ -134,7 +134,7 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
# 3. Change the preset to Boost (we should stay in SECURITY) # 3. Change the preset to Boost (we should stay in SECURITY)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on: ) as mock_heater_on:
@@ -149,7 +149,7 @@ async def test_security_feature(hass: HomeAssistant, skip_hass_states_is_state):
# 5. resolve the datetime issue # 5. resolve the datetime issue
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on: ) as mock_heater_on:
@@ -214,7 +214,7 @@ async def test_security_over_climate(
fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {}, HVACMode.HEAT) fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {}, HVACMode.HEAT)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate", "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate",
return_value=fake_underlying_climate, return_value=fake_underlying_climate,
@@ -292,7 +292,7 @@ async def test_security_over_climate(
# 2. activate security feature when date is expired # 2. activate security feature when date is expired
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on: ) as mock_heater_on:

View File

@@ -12,7 +12,7 @@ from homeassistant.const import UnitOfTime, UnitOfPower, UnitOfEnergy, PERCENTAG
from pytest_homeassistant_custom_component.common import MockConfigEntry from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.versatile_thermostat.climate import VersatileThermostat from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
from custom_components.versatile_thermostat.sensor import ( from custom_components.versatile_thermostat.sensor import (
EnergySensor, EnergySensor,
MeanPowerSensor, MeanPowerSensor,

View File

@@ -10,7 +10,7 @@ from homeassistant.components.climate import ClimateEntity, DOMAIN as CLIMATE_DO
from pytest_homeassistant_custom_component.common import MockConfigEntry from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.versatile_thermostat.climate import VersatileThermostat from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import
@@ -28,7 +28,7 @@ async def test_over_switch_full_start(hass: HomeAssistant, skip_hass_states_is_s
) )
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event: ) as mock_send_event:
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
@@ -93,7 +93,7 @@ async def test_over_climate_full_start(hass: HomeAssistant, skip_hass_states_is_
fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {}) fake_underlying_climate = MockClimate(hass, "mockUniqueId", "MockClimateName", {})
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate", "custom_components.versatile_thermostat.underlyings.UnderlyingClimate.find_underlying_climate",
return_value=fake_underlying_climate, return_value=fake_underlying_climate,
@@ -160,7 +160,7 @@ async def test_over_4switch_full_start(hass: HomeAssistant, skip_hass_states_is_
) )
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event: ) as mock_send_event:
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)

View File

@@ -11,7 +11,7 @@ from homeassistant.components.climate import ClimateEntity, DOMAIN as CLIMATE_DO
from pytest_homeassistant_custom_component.common import MockConfigEntry from pytest_homeassistant_custom_component.common import MockConfigEntry
from custom_components.versatile_thermostat.climate import VersatileThermostat from custom_components.versatile_thermostat.base_thermostat import BaseThermostat
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import
@@ -31,7 +31,7 @@ async def test_over_switch_ac_full_start(hass: HomeAssistant, skip_hass_states_i
now: datetime = datetime.now(tz=tz) now: datetime = datetime.now(tz=tz)
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event: ) as mock_send_event:
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
@@ -45,7 +45,7 @@ async def test_over_switch_ac_full_start(hass: HomeAssistant, skip_hass_states_i
return entity return entity
# The name is in the CONF and not the title of the entry # The name is in the CONF and not the title of the entry
entity: VersatileThermostat = find_my_entity("climate.theoverswitchmockname") entity: BaseThermostat = find_my_entity("climate.theoverswitchmockname")
assert entity assert entity

View File

@@ -66,7 +66,7 @@ async def test_window_management_time_not_enough(
# Open the window, but condition of time is not satisfied and check the thermostat don't turns off # Open the window, but condition of time is not satisfied and check the thermostat don't turns off
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -154,7 +154,7 @@ async def test_window_management_time_enough(
# change temperature to force turning on the heater # change temperature to force turning on the heater
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -172,7 +172,7 @@ async def test_window_management_time_enough(
# Open the window, condition of time is satisfied, check the thermostat and heater turns off # Open the window, condition of time is satisfied, check the thermostat and heater turns off
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -200,7 +200,7 @@ async def test_window_management_time_enough(
# Close the window # Close the window
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -296,7 +296,7 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state):
# Make the temperature down # Make the temperature down
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -318,7 +318,7 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state):
# send one degre down in one minute # send one degre down in one minute
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -353,7 +353,7 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state):
# send another 0.1 degre in one minute -> no change # send another 0.1 degre in one minute -> no change
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -378,7 +378,7 @@ async def test_window_auto_fast(hass: HomeAssistant, skip_hass_states_is_state):
# send another plus 1.1 degre in one minute -> restore state # send another plus 1.1 degre in one minute -> restore state
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -480,7 +480,7 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
# Make the temperature down # Make the temperature down
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -501,7 +501,7 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
# send one degre down in one minute # send one degre down in one minute
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -539,7 +539,7 @@ async def test_window_auto_auto_stop(hass: HomeAssistant, skip_hass_states_is_st
# Waits for automatic disable # Waits for automatic disable
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -625,7 +625,7 @@ async def test_window_auto_no_on_percent(
# Make the temperature down # Make the temperature down
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(
@@ -647,7 +647,7 @@ async def test_window_auto_no_on_percent(
# send one degre down in one minute # send one degre down in one minute
with patch( with patch(
"custom_components.versatile_thermostat.climate.VersatileThermostat.send_event" "custom_components.versatile_thermostat.base_thermostat.BaseThermostat.send_event"
) as mock_send_event, patch( ) as mock_send_event, patch(
"custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on" "custom_components.versatile_thermostat.underlyings.UnderlyingSwitch.turn_on"
) as mock_heater_on, patch( ) as mock_heater_on, patch(