Use show_advanced_options in devolo home control (#35360)

This commit is contained in:
Markus Bong authored and GitHub committed 2020-06-02 17:52:36 -07:00
1 parent a5d520b603
commit e94228fddf
2 files changed
+60 -22

No files matched your search

@@ -30,12 +30,7 @@ async def test_form(hass):
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"username": "test-username",
"password": "test-password",
"home_control_url": "https://homecontrol.mydevolo.com",
"mydevolo_url": "https://www.mydevolo.com",
},
{"username": "test-username", "password": "test-password"},
)
assert result2["type"] == "create_entry"
@@ -67,12 +62,7 @@ async def test_form_invalid_credentials(hass):
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"username": "test-username",
"password": "test-password",
"home_control_url": "https://homecontrol.mydevolo.com",
"mydevolo_url": "https://www.mydevolo.com",
},
{"username": "test-username", "password": "test-password"},
)
assert result["errors"] == {"base": "invalid_credentials"}
@@ -91,12 +81,51 @@ async def test_form_already_configured(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={
"username": "test-username",
"password": "test-password",
"home_control_url": "https://homecontrol.mydevolo.com",
"mydevolo_url": "https://www.mydevolo.com",
},
data={"username": "test-username", "password": "test-password"},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
async def test_form_advanced_options(hass):
"""Test if we get the advanced options if user has enabled it."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user", "show_advanced_options": True}
)
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
"homeassistant.components.devolo_home_control.async_setup", return_value=True,
) as mock_setup, patch(
"homeassistant.components.devolo_home_control.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.credentials_valid",
return_value=True,
), patch(
"homeassistant.components.devolo_home_control.config_flow.Mydevolo.get_gateway_ids",
return_value=["123456"],
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"username": "test-username",
"password": "test-password",
"home_control_url": "https://test_url.test",
"mydevolo_url": "https://test_mydevolo_url.test",
},
)
assert result2["type"] == "create_entry"
assert result2["title"] == "devolo Home Control"
assert result2["data"] == {
"username": "test-username",
"password": "test-password",
"home_control_url": "https://test_url.test",
"mydevolo_url": "https://test_mydevolo_url.test",
}
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1