Add support for AdGuard Home v0.99.0 (#27926)
* Bump adguardhome to 0.3.0 * Add a more user friendly version handling and added logs * ✏️ Fixes spelling error in abort messages * ✏️ Error messages improvements, suggested by cgtobi
This commit is contained in:
parent
48e5655379
commit
cb061e57d2
9 changed files with 116 additions and 15 deletions
|
@ -3,9 +3,9 @@ from unittest.mock import patch
|
|||
|
||||
import aiohttp
|
||||
|
||||
from homeassistant import data_entry_flow, config_entries
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.adguard import config_flow
|
||||
from homeassistant.components.adguard.const import DOMAIN
|
||||
from homeassistant.components.adguard.const import DOMAIN, MIN_ADGUARD_HOME_VERSION
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
|
@ -65,7 +65,7 @@ async def test_full_flow_implementation(hass, aioclient_mock):
|
|||
FIXTURE_USER_INPUT[CONF_HOST],
|
||||
FIXTURE_USER_INPUT[CONF_PORT],
|
||||
),
|
||||
json={"version": "1.0"},
|
||||
json={"version": "v0.99.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
|
@ -133,8 +133,19 @@ async def test_hassio_update_instance_not_running(hass):
|
|||
assert result["reason"] == "existing_instance_updated"
|
||||
|
||||
|
||||
async def test_hassio_update_instance_running(hass):
|
||||
async def test_hassio_update_instance_running(hass, aioclient_mock):
|
||||
"""Test we only allow a single config flow."""
|
||||
aioclient_mock.get(
|
||||
"http://mock-adguard-updated:3000/control/status",
|
||||
json={"version": "v0.99.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"http://mock-adguard:3000/control/status",
|
||||
json={"version": "v0.99.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain="adguard",
|
||||
data={
|
||||
|
@ -187,7 +198,7 @@ async def test_hassio_confirm(hass, aioclient_mock):
|
|||
"""Test we can finish a config flow."""
|
||||
aioclient_mock.get(
|
||||
"http://mock-adguard:3000/control/status",
|
||||
json={"version": "1.0"},
|
||||
json={"version": "v0.99.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
|
@ -228,3 +239,54 @@ async def test_hassio_connection_error(hass, aioclient_mock):
|
|||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
assert result["errors"] == {"base": "connection_error"}
|
||||
|
||||
|
||||
async def test_outdated_adguard_version(hass, aioclient_mock):
|
||||
"""Test we show abort when connecting with unsupported AdGuard version."""
|
||||
aioclient_mock.get(
|
||||
"{}://{}:{}/control/status".format(
|
||||
"https" if FIXTURE_USER_INPUT[CONF_SSL] else "http",
|
||||
FIXTURE_USER_INPUT[CONF_HOST],
|
||||
FIXTURE_USER_INPUT[CONF_PORT],
|
||||
),
|
||||
json={"version": "v0.98.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
flow = config_flow.AdGuardHomeFlowHandler()
|
||||
flow.hass = hass
|
||||
result = await flow.async_step_user(user_input=None)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await flow.async_step_user(user_input=FIXTURE_USER_INPUT)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "adguard_home_outdated"
|
||||
assert result["description_placeholders"] == {
|
||||
"current_version": "v0.98.0",
|
||||
"minimal_version": MIN_ADGUARD_HOME_VERSION,
|
||||
}
|
||||
|
||||
|
||||
async def test_outdated_adguard_addon_version(hass, aioclient_mock):
|
||||
"""Test we show abort when connecting with unsupported AdGuard add-on version."""
|
||||
aioclient_mock.get(
|
||||
"http://mock-adguard:3000/control/status",
|
||||
json={"version": "v0.98.0"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"adguard",
|
||||
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": 3000},
|
||||
context={"source": "hassio"},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "adguard_home_addon_outdated"
|
||||
assert result["description_placeholders"] == {
|
||||
"current_version": "v0.98.0",
|
||||
"minimal_version": MIN_ADGUARD_HOME_VERSION,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue