Move imports in nuheat component (#28038)
* Move imports in nuheat component * Fix tox tests * Fix tox tests * Update tests/components/nuheat/test_init.py @Balloob suggested the change because direct replacement, the mock would never be reverted and impact the other tests. Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
b1a374062b
commit
14be60e5bf
3 changed files with 9 additions and 10 deletions
|
@ -1,11 +1,11 @@
|
||||||
"""Support for NuHeat thermostats."""
|
"""Support for NuHeat thermostats."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import nuheat
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_DEVICES
|
from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
from homeassistant.helpers import discovery
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ CONFIG_SCHEMA = vol.Schema(
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the NuHeat thermostat component."""
|
"""Set up the NuHeat thermostat component."""
|
||||||
import nuheat
|
|
||||||
|
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
username = conf.get(CONF_USERNAME)
|
username = conf.get(CONF_USERNAME)
|
||||||
password = conf.get(CONF_PASSWORD)
|
password = conf.get(CONF_PASSWORD)
|
||||||
|
|
|
@ -9,9 +9,9 @@ from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_AUTO,
|
HVAC_MODE_AUTO,
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
|
PRESET_NONE,
|
||||||
SUPPORT_PRESET_MODE,
|
SUPPORT_PRESET_MODE,
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
SUPPORT_TARGET_TEMPERATURE,
|
||||||
PRESET_NONE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""NuHeat component tests."""
|
"""NuHeat component tests."""
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
from tests.common import get_test_home_assistant, MockDependency
|
|
||||||
|
|
||||||
from homeassistant.components import nuheat
|
from homeassistant.components import nuheat
|
||||||
|
|
||||||
|
from tests.common import MockDependency, get_test_home_assistant
|
||||||
|
|
||||||
VALID_CONFIG = {
|
VALID_CONFIG = {
|
||||||
"nuheat": {"username": "warm", "password": "feet", "devices": "thermostat123"}
|
"nuheat": {"username": "warm", "password": "feet", "devices": "thermostat123"}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,12 @@ class TestNuHeat(unittest.TestCase):
|
||||||
@patch("homeassistant.helpers.discovery.load_platform")
|
@patch("homeassistant.helpers.discovery.load_platform")
|
||||||
def test_setup(self, mocked_nuheat, mocked_load):
|
def test_setup(self, mocked_nuheat, mocked_load):
|
||||||
"""Test setting up the NuHeat component."""
|
"""Test setting up the NuHeat component."""
|
||||||
nuheat.setup(self.hass, self.config)
|
with patch.object(nuheat, "nuheat", mocked_nuheat):
|
||||||
|
nuheat.setup(self.hass, self.config)
|
||||||
|
|
||||||
mocked_nuheat.NuHeat.assert_called_with("warm", "feet")
|
mocked_nuheat.NuHeat.assert_called_with("warm", "feet")
|
||||||
assert nuheat.DOMAIN in self.hass.data
|
assert nuheat.DOMAIN in self.hass.data
|
||||||
assert 2 == len(self.hass.data[nuheat.DOMAIN])
|
assert len(self.hass.data[nuheat.DOMAIN]) == 2
|
||||||
assert isinstance(
|
assert isinstance(
|
||||||
self.hass.data[nuheat.DOMAIN][0], type(mocked_nuheat.NuHeat())
|
self.hass.data[nuheat.DOMAIN][0], type(mocked_nuheat.NuHeat())
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue