mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Dynalite Integration (#27841)
* Initial commit * ran hassfest and gen_requirements_all scripts * fixes per request from Paulus Schoutsen * ran gen_requirements_all * updated library version - removed some debug leftover * get_requirements again... * added documentation URL * ran isort * changed storage in hass.data[DOMAIN] to use entry_id instead of host * adopted unit tests to latest fix * Update const.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
36
tests/components/dynalite/test_config_flow.py
Executable file
36
tests/components/dynalite/test_config_flow.py
Executable file
@@ -0,0 +1,36 @@
|
||||
"""Test Dynalite config flow."""
|
||||
from unittest.mock import Mock, call, patch
|
||||
|
||||
from homeassistant.components.dynalite import config_flow
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
async def test_step_import():
|
||||
"""Test a successful setup."""
|
||||
flow_handler = config_flow.DynaliteFlowHandler()
|
||||
with patch.object(flow_handler, "context", create=True):
|
||||
with patch.object(flow_handler, "hass", create=True) as mock_hass:
|
||||
with patch.object(
|
||||
flow_handler, "async_create_entry", create=True
|
||||
) as mock_create:
|
||||
host = "1.2.3.4"
|
||||
entry1 = Mock()
|
||||
entry1.data = {"host": host}
|
||||
entry2 = Mock()
|
||||
entry2.data = {"host": "5.5"}
|
||||
mock_hass.config_entries.async_entries = Mock(
|
||||
return_value=[entry1, entry2]
|
||||
)
|
||||
mock_hass.config_entries.async_remove = Mock(
|
||||
return_value=mock_coro(Mock())
|
||||
)
|
||||
await flow_handler.async_step_import({"host": "1.2.3.4"})
|
||||
mock_hass.config_entries.async_remove.assert_called_once()
|
||||
assert mock_hass.config_entries.async_remove.mock_calls[0] == call(
|
||||
entry1.entry_id
|
||||
)
|
||||
mock_create.assert_called_once()
|
||||
assert mock_create.mock_calls[0] == call(
|
||||
title=host, data={"host": host}
|
||||
)
|
||||
Reference in New Issue
Block a user