allow overriding host api url in config flow (#33481)
* allow overriding host api url in config flow * fix typo * capitalize URL
This commit is contained in:
1 parent
b892dbc6ea
commit
955c94e313
7 files changed
+91
-20
No files matched your search
@@ -450,6 +450,7 @@ async def test_import_existing_config(hass, mock_panel):
|
||||
"alarm1": "Switchable Output",
|
||||
},
|
||||
"blink": True,
|
||||
"api_host": "",
|
||||
"discovery": True,
|
||||
"binary_sensors": [
|
||||
{"zone": "2", "type": "door", "inverse": False},
|
||||
@@ -628,6 +629,7 @@ async def test_import_pin_config(hass, mock_panel):
|
||||
"out": "Switchable Output",
|
||||
},
|
||||
"blink": True,
|
||||
"api_host": "",
|
||||
"discovery": True,
|
||||
"binary_sensors": [
|
||||
{"zone": "1", "type": "door", "inverse": False},
|
||||
@@ -778,9 +780,21 @@ async def test_option_flow(hass, mock_panel):
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "options_misc"
|
||||
|
||||
# make sure we enforce url format
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], user_input={"blink": True},
|
||||
result["flow_id"],
|
||||
user_input={"blink": True, "override_api_host": True, "api_host": "badhosturl"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "options_misc"
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
"blink": True,
|
||||
"override_api_host": True,
|
||||
"api_host": "http://overridehost:1111",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["data"] == {
|
||||
@@ -792,6 +806,7 @@ async def test_option_flow(hass, mock_panel):
|
||||
"out": "Switchable Output",
|
||||
},
|
||||
"blink": True,
|
||||
"api_host": "http://overridehost:1111",
|
||||
"binary_sensors": [
|
||||
{"zone": "2", "type": "door", "inverse": False},
|
||||
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
|
||||
@@ -958,7 +973,7 @@ async def test_option_flow_pro(hass, mock_panel):
|
||||
assert result["step_id"] == "options_misc"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], user_input={"blink": True},
|
||||
result["flow_id"], user_input={"blink": True, "override_api_host": False},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
@@ -976,6 +991,7 @@ async def test_option_flow_pro(hass, mock_panel):
|
||||
"out1": "Switchable Output",
|
||||
},
|
||||
"blink": True,
|
||||
"api_host": "",
|
||||
"binary_sensors": [
|
||||
{"zone": "2", "type": "door", "inverse": False},
|
||||
{"zone": "6", "type": "window", "name": "winder", "inverse": True},
|
||||
@@ -1121,7 +1137,7 @@ async def test_option_flow_import(hass, mock_panel):
|
||||
schema = result["data_schema"]({})
|
||||
assert schema["blink"] is True
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], user_input={"blink": False},
|
||||
result["flow_id"], user_input={"blink": False, "override_api_host": False},
|
||||
)
|
||||
|
||||
# verify the updated fields
|
||||
@@ -1129,6 +1145,7 @@ async def test_option_flow_import(hass, mock_panel):
|
||||
assert result["data"] == {
|
||||
"io": {"1": "Binary Sensor", "2": "Digital Sensor", "3": "Switchable Output"},
|
||||
"blink": False,
|
||||
"api_host": "",
|
||||
"binary_sensors": [
|
||||
{"zone": "1", "type": "door", "inverse": True, "name": "winder"},
|
||||
],
|
||||
|
||||
@@ -43,6 +43,7 @@ async def test_config_schema(hass):
|
||||
"""Test that config schema is imported properly."""
|
||||
config = {
|
||||
konnected.DOMAIN: {
|
||||
konnected.CONF_API_HOST: "http://1.1.1.1:8888",
|
||||
konnected.CONF_ACCESS_TOKEN: "abcdefgh",
|
||||
konnected.CONF_DEVICES: [{konnected.CONF_ID: "aabbccddeeff"}],
|
||||
}
|
||||
@@ -50,10 +51,12 @@ async def test_config_schema(hass):
|
||||
assert konnected.CONFIG_SCHEMA(config) == {
|
||||
"konnected": {
|
||||
"access_token": "abcdefgh",
|
||||
"api_host": "http://1.1.1.1:8888",
|
||||
"devices": [
|
||||
{
|
||||
"default_options": {
|
||||
"blink": True,
|
||||
"api_host": "http://1.1.1.1:8888",
|
||||
"discovery": True,
|
||||
"io": {
|
||||
"1": "Disabled",
|
||||
@@ -96,6 +99,7 @@ async def test_config_schema(hass):
|
||||
{
|
||||
"default_options": {
|
||||
"blink": True,
|
||||
"api_host": "",
|
||||
"discovery": True,
|
||||
"io": {
|
||||
"1": "Disabled",
|
||||
@@ -162,6 +166,7 @@ async def test_config_schema(hass):
|
||||
{
|
||||
"default_options": {
|
||||
"blink": True,
|
||||
"api_host": "",
|
||||
"discovery": True,
|
||||
"io": {
|
||||
"1": "Binary Sensor",
|
||||
|
||||
Reference in new issue
Block a user