diff --git a/homeassistant/components/nuheat/__init__.py b/homeassistant/components/nuheat/__init__.py index f83611d3e40..88e10270d18 100644 --- a/homeassistant/components/nuheat/__init__.py +++ b/homeassistant/components/nuheat/__init__.py @@ -1,11 +1,11 @@ """Support for NuHeat thermostats.""" import logging +import nuheat import voluptuous as vol -from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_DEVICES -from homeassistant.helpers import config_validation as cv -from homeassistant.helpers import discovery +from homeassistant.const import CONF_DEVICES, CONF_PASSWORD, CONF_USERNAME +from homeassistant.helpers import config_validation as cv, discovery _LOGGER = logging.getLogger(__name__) @@ -29,8 +29,6 @@ CONFIG_SCHEMA = vol.Schema( def setup(hass, config): """Set up the NuHeat thermostat component.""" - import nuheat - conf = config[DOMAIN] username = conf.get(CONF_USERNAME) password = conf.get(CONF_PASSWORD) diff --git a/homeassistant/components/nuheat/climate.py b/homeassistant/components/nuheat/climate.py index 19780a35a20..5a4e4e233d1 100644 --- a/homeassistant/components/nuheat/climate.py +++ b/homeassistant/components/nuheat/climate.py @@ -9,9 +9,9 @@ from homeassistant.components.climate.const import ( HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF, + PRESET_NONE, SUPPORT_PRESET_MODE, SUPPORT_TARGET_TEMPERATURE, - PRESET_NONE, ) from homeassistant.const import ( ATTR_ENTITY_ID, diff --git a/tests/components/nuheat/test_init.py b/tests/components/nuheat/test_init.py index a6be3ac14f5..90a209fd897 100644 --- a/tests/components/nuheat/test_init.py +++ b/tests/components/nuheat/test_init.py @@ -1,11 +1,11 @@ """NuHeat component tests.""" import unittest - from unittest.mock import patch -from tests.common import get_test_home_assistant, MockDependency from homeassistant.components import nuheat +from tests.common import MockDependency, get_test_home_assistant + VALID_CONFIG = { "nuheat": {"username": "warm", "password": "feet", "devices": "thermostat123"} } @@ -27,11 +27,12 @@ class TestNuHeat(unittest.TestCase): @patch("homeassistant.helpers.discovery.load_platform") def test_setup(self, mocked_nuheat, mocked_load): """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") 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( self.hass.data[nuheat.DOMAIN][0], type(mocked_nuheat.NuHeat()) )