Fix setting up multiple UPSes with NUT in 0.108.x (#34427)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-04-21 10:47:31 -07:00
1 parent 334fecdf6f
commit 5635cdb77c
2 files changed
+12 -2

No files matched your search

+9 -1
View File
@@ -4,6 +4,8 @@ from asynctest import MagicMock, patch
from homeassistant import config_entries, setup
from homeassistant.components.nut.const import DOMAIN
from tests.common import MockConfigEntry
def _get_mock_pynutclient(list_vars=None):
pynutclient = MagicMock()
@@ -62,6 +64,12 @@ async def test_form_import(hass):
"""Test we get the form with import source."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
data={"host": "2.2.2.2", "port": 123, "resources": ["battery.charge"]},
)
config_entry.add_to_hass(hass)
mock_pynut = _get_mock_pynutclient(list_vars={"battery.voltage": "serial"})
with patch(
@@ -92,7 +100,7 @@ async def test_form_import(hass):
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 2
async def test_form_cannot_connect(hass):