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:
Diefferson Koderer MôroandPaulus Schoutsen authored and Paulus Schoutsen committed 2019-10-23 08:30:38 -07:00
1 parent b1a374062b
commit 14be60e5bf
3 files changed
+9 -10

No files matched your search

+5 -4
View File
@@ -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())
)