Switch rfxtrx to config entries (#37794)
* Switch to config flow setup * Add minimal test for config flow * Add myself as codeowner and address some review concerns * Address some further review comments
This commit is contained in:
1 parent
ed3f25489e
commit
1a64108eea
13 files changed
+228
-71
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""Test the Tado config flow."""
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components.rfxtrx import DOMAIN
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_import(hass):
|
||||
"""Test we can import."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={"host": None, "port": None, "device": "/dev/tty123", "debug": False},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "RFXTRX"
|
||||
assert result["data"] == {
|
||||
"host": None,
|
||||
"port": None,
|
||||
"device": "/dev/tty123",
|
||||
"debug": False,
|
||||
}
|
||||
|
||||
|
||||
async def test_import_update(hass):
|
||||
"""Test we can import."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={"host": None, "port": None, "device": "/dev/tty123", "debug": False},
|
||||
unique_id=DOMAIN,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={"host": None, "port": None, "device": "/dev/tty123", "debug": True},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["debug"]
|
||||
Reference in new issue
Block a user