Files
home-assistant-core/tests/components/nuheat/mocks.py
T
J. Nick Koston b09a9fc81a Add config flow for Nuheat (#32885)
* Modernize nuheat for new climate platform

* Home Assistant state now mirrors the
  state displayed at mynewheat.com

* Remove off mode as the device does not implement
  and setting was not implemented anyways

* Implement missing set_hvac_mode for nuheat

* Now shows as unavailable when offline

* Add a unique id (serial number)

* Fix hvac_mode as it was really implementing hvac_action

* Presets now map to the open api spec
  published at https://api.mynuheat.com/swagger/

* ThermostatModel: scheduleMode

* Revert test cleanup as it leaves files behind.

Its going to be more invasive to modernize the tests so
it will have to come in a new pr

* Config flow for nuheat

* codeowners

* Add an import test as well

* remove debug
2020-03-23 00:29:45 -05:00

122 lines
3.1 KiB
Python

"""The test for the NuHeat thermostat module."""
from asynctest.mock import MagicMock, Mock
from nuheat.config import SCHEDULE_HOLD, SCHEDULE_RUN, SCHEDULE_TEMPORARY_HOLD
from homeassistant.components.nuheat.const import DOMAIN
from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME
def _get_mock_thermostat_run():
serial_number = "12345"
thermostat = Mock(
serial_number=serial_number,
room="Master bathroom",
online=True,
heating=True,
temperature=2222,
celsius=22,
fahrenheit=72,
max_celsius=69,
max_fahrenheit=157,
min_celsius=5,
min_fahrenheit=41,
schedule_mode=SCHEDULE_RUN,
target_celsius=22,
target_fahrenheit=72,
)
thermostat.get_data = Mock()
thermostat.resume_schedule = Mock()
thermostat.schedule_mode = Mock()
return thermostat
def _get_mock_thermostat_schedule_hold_unavailable():
serial_number = "876"
thermostat = Mock(
serial_number=serial_number,
room="Guest bathroom",
online=False,
heating=False,
temperature=12,
celsius=12,
fahrenheit=102,
max_celsius=99,
max_fahrenheit=357,
min_celsius=9,
min_fahrenheit=21,
schedule_mode=SCHEDULE_HOLD,
target_celsius=23,
target_fahrenheit=79,
)
thermostat.get_data = Mock()
thermostat.resume_schedule = Mock()
thermostat.schedule_mode = Mock()
return thermostat
def _get_mock_thermostat_schedule_hold_available():
serial_number = "876"
thermostat = Mock(
serial_number=serial_number,
room="Available bathroom",
online=True,
heating=False,
temperature=12,
celsius=12,
fahrenheit=102,
max_celsius=99,
max_fahrenheit=357,
min_celsius=9,
min_fahrenheit=21,
schedule_mode=SCHEDULE_HOLD,
target_celsius=23,
target_fahrenheit=79,
)
thermostat.get_data = Mock()
thermostat.resume_schedule = Mock()
thermostat.schedule_mode = Mock()
return thermostat
def _get_mock_thermostat_schedule_temporary_hold():
serial_number = "999"
thermostat = Mock(
serial_number=serial_number,
room="Temp bathroom",
online=True,
heating=False,
temperature=14,
celsius=13,
fahrenheit=202,
max_celsius=39,
max_fahrenheit=357,
min_celsius=3,
min_fahrenheit=31,
schedule_mode=SCHEDULE_TEMPORARY_HOLD,
target_celsius=43,
target_fahrenheit=99,
)
thermostat.get_data = Mock()
thermostat.resume_schedule = Mock()
thermostat.schedule_mode = Mock()
return thermostat
def _get_mock_nuheat(authenticate=None, get_thermostat=None):
nuheat_mock = MagicMock()
type(nuheat_mock).authenticate = MagicMock()
type(nuheat_mock).get_thermostat = MagicMock(return_value=get_thermostat)
return nuheat_mock
def _mock_get_config():
"""Return a default nuheat config."""
return {
DOMAIN: {CONF_USERNAME: "me", CONF_PASSWORD: "secret", CONF_DEVICES: [12345]}
}