Fix options for dnsip (#65369)

This commit is contained in:
G Johansson
2022-02-01 09:59:22 -08:00
committed by Paulus Schoutsen
parent 055382c84c
commit 03bd3f5001
3 changed files with 39 additions and 18 deletions
+33 -12
View File
@@ -69,11 +69,13 @@ async def test_form(hass: HomeAssistant) -> None:
assert result2["data"] == {
"hostname": "home-assistant.io",
"name": "home-assistant.io",
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
"ipv4": True,
"ipv6": True,
}
assert result2["options"] == {
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
}
assert len(mock_setup_entry.mock_calls) == 1
@@ -101,34 +103,41 @@ async def test_form_error(hass: HomeAssistant) -> None:
@pytest.mark.parametrize(
"p_input,p_output",
"p_input,p_output,p_options",
[
(
{CONF_HOSTNAME: "home-assistant.io"},
{
"hostname": "home-assistant.io",
"name": "home-assistant.io",
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
"ipv4": True,
"ipv6": True,
},
{
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
},
),
(
{},
{
"hostname": "myip.opendns.com",
"name": "myip",
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
"ipv4": True,
"ipv6": True,
},
{
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:0:ccc::2",
},
),
],
)
async def test_import_flow_success(
hass: HomeAssistant, p_input: dict[str, str], p_output: dict[str, str]
hass: HomeAssistant,
p_input: dict[str, str],
p_output: dict[str, str],
p_options: dict[str, str],
) -> None:
"""Test a successful import of YAML."""
@@ -149,6 +158,7 @@ async def test_import_flow_success(
assert result2["type"] == RESULT_TYPE_CREATE_ENTRY
assert result2["title"] == p_output["name"]
assert result2["data"] == p_output
assert result2["options"] == p_options
assert len(mock_setup_entry.mock_calls) == 1
@@ -160,11 +170,13 @@ async def test_flow_already_exist(hass: HomeAssistant) -> None:
data={
CONF_HOSTNAME: "home-assistant.io",
CONF_NAME: "home-assistant.io",
CONF_RESOLVER: "208.67.222.222",
CONF_RESOLVER_IPV6: "2620:0:ccc::2",
CONF_IPV4: True,
CONF_IPV6: True,
},
options={
CONF_RESOLVER: "208.67.222.222",
CONF_RESOLVER_IPV6: "2620:0:ccc::2",
},
unique_id="home-assistant.io",
).add_to_hass(hass)
@@ -199,11 +211,13 @@ async def test_options_flow(hass: HomeAssistant) -> None:
data={
CONF_HOSTNAME: "home-assistant.io",
CONF_NAME: "home-assistant.io",
CONF_RESOLVER: "208.67.222.222",
CONF_RESOLVER_IPV6: "2620:0:ccc::2",
CONF_IPV4: True,
CONF_IPV6: False,
},
options={
CONF_RESOLVER: "208.67.222.222",
CONF_RESOLVER_IPV6: "2620:0:ccc::2",
},
)
entry.add_to_hass(hass)
@@ -267,6 +281,13 @@ async def test_options_error(hass: HomeAssistant, p_input: dict[str, str]) -> No
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.dnsip.async_setup_entry",
return_value=True,
):
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
with patch(