mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Small improvements to the AdGuard tests (#133073)
This commit is contained in:
parent
3baa432bae
commit
839f06b2dc
@ -1 +1 @@
|
||||
"""Tests for the AdGuard Home component."""
|
||||
"""Tests for the AdGuard Home integration."""
|
||||
|
@ -59,9 +59,9 @@ async def test_connection_error(
|
||||
)
|
||||
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("errors") == {"base": "cannot_connect"}
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_full_flow_implementation(
|
||||
@ -83,25 +83,27 @@ async def test_full_flow_implementation(
|
||||
)
|
||||
|
||||
assert result
|
||||
assert result.get("flow_id")
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result["flow_id"]
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=FIXTURE_USER_INPUT
|
||||
)
|
||||
assert result2
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == FIXTURE_USER_INPUT[CONF_HOST]
|
||||
assert result
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
data = result2.get("data")
|
||||
assert data
|
||||
assert data[CONF_HOST] == FIXTURE_USER_INPUT[CONF_HOST]
|
||||
assert data[CONF_PASSWORD] == FIXTURE_USER_INPUT[CONF_PASSWORD]
|
||||
assert data[CONF_PORT] == FIXTURE_USER_INPUT[CONF_PORT]
|
||||
assert data[CONF_SSL] == FIXTURE_USER_INPUT[CONF_SSL]
|
||||
assert data[CONF_USERNAME] == FIXTURE_USER_INPUT[CONF_USERNAME]
|
||||
assert data[CONF_VERIFY_SSL] == FIXTURE_USER_INPUT[CONF_VERIFY_SSL]
|
||||
config_entry = result["result"]
|
||||
assert config_entry.title == FIXTURE_USER_INPUT[CONF_HOST]
|
||||
assert config_entry.data == {
|
||||
CONF_HOST: FIXTURE_USER_INPUT[CONF_HOST],
|
||||
CONF_PASSWORD: FIXTURE_USER_INPUT[CONF_PASSWORD],
|
||||
CONF_PORT: FIXTURE_USER_INPUT[CONF_PORT],
|
||||
CONF_SSL: FIXTURE_USER_INPUT[CONF_SSL],
|
||||
CONF_USERNAME: FIXTURE_USER_INPUT[CONF_USERNAME],
|
||||
CONF_VERIFY_SSL: FIXTURE_USER_INPUT[CONF_VERIFY_SSL],
|
||||
}
|
||||
assert not config_entry.options
|
||||
|
||||
|
||||
async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||
@ -116,8 +118,8 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_hassio_already_configured(hass: HomeAssistant) -> None:
|
||||
@ -141,8 +143,8 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||
@ -166,8 +168,8 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_hassio_confirm(
|
||||
@ -195,24 +197,25 @@ async def test_hassio_confirm(
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "hassio_confirm"
|
||||
assert result.get("description_placeholders") == {"addon": "AdGuard Home Addon"}
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
assert result["description_placeholders"] == {"addon": "AdGuard Home Addon"}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == "AdGuard Home Addon"
|
||||
assert result
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
data = result2.get("data")
|
||||
assert data
|
||||
assert data[CONF_HOST] == "mock-adguard"
|
||||
assert data[CONF_PASSWORD] is None
|
||||
assert data[CONF_PORT] == 3000
|
||||
assert data[CONF_SSL] is False
|
||||
assert data[CONF_USERNAME] is None
|
||||
assert data[CONF_VERIFY_SSL]
|
||||
config_entry = result["result"]
|
||||
assert config_entry.title == "AdGuard Home Addon"
|
||||
assert config_entry.data == {
|
||||
CONF_HOST: "mock-adguard",
|
||||
CONF_PASSWORD: None,
|
||||
CONF_PORT: 3000,
|
||||
CONF_SSL: False,
|
||||
CONF_USERNAME: None,
|
||||
CONF_VERIFY_SSL: True,
|
||||
}
|
||||
|
||||
|
||||
async def test_hassio_connection_error(
|
||||
@ -241,6 +244,6 @@ async def test_hassio_connection_error(
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "hassio_confirm"
|
||||
assert result.get("errors") == {"base": "cannot_connect"}
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user