Use config_entries.SOURCE_* constants (#49631)
This commit is contained in:
parent
34a588d1ba
commit
153d6e891e
103 changed files with 723 additions and 488 deletions
|
@ -199,7 +199,7 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
parsed_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION])
|
parsed_url = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION])
|
||||||
|
|
||||||
entry = await self.async_set_unique_id(self.bridge_id)
|
entry = await self.async_set_unique_id(self.bridge_id)
|
||||||
if entry and entry.source == "hassio":
|
if entry and entry.source == config_entries.SOURCE_HASSIO:
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
self._abort_if_unique_id_configured(
|
self._abort_if_unique_id_configured(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import HTTPServiceUnavailable
|
from aiohttp.web_exceptions import HTTPServiceUnavailable
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.const import ATTR_NAME, ATTR_SERVICE, EVENT_HOMEASSISTANT_START
|
from homeassistant.const import ATTR_NAME, ATTR_SERVICE, EVENT_HOMEASSISTANT_START
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
@ -87,7 +88,7 @@ class HassIODiscovery(HomeAssistantView):
|
||||||
|
|
||||||
# Use config flow
|
# Use config flow
|
||||||
await self.hass.config_entries.flow.async_init(
|
await self.hass.config_entries.flow.async_init(
|
||||||
service, context={"source": "hassio"}, data=config_data
|
service, context={"source": config_entries.SOURCE_HASSIO}, data=config_data
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_process_del(self, data):
|
async def async_process_del(self, data):
|
||||||
|
@ -106,6 +107,6 @@ class HassIODiscovery(HomeAssistantView):
|
||||||
|
|
||||||
# Use config flow
|
# Use config flow
|
||||||
for entry in self.hass.config_entries.async_entries(service):
|
for entry in self.hass.config_entries.async_entries(service):
|
||||||
if entry.source != "hassio":
|
if entry.source != config_entries.SOURCE_HASSIO:
|
||||||
continue
|
continue
|
||||||
await self.hass.config_entries.async_remove(entry)
|
await self.hass.config_entries.async_remove(entry)
|
||||||
|
|
|
@ -9,7 +9,7 @@ from pyheos import Heos, HeosError, const as heos_const
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN
|
from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
@ -47,7 +47,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
||||||
# Create new entry based on config
|
# Create new entry based on config
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={CONF_HOST: host}
|
DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_HOST: host}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -3,6 +3,7 @@ import socket
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN
|
from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -53,7 +54,9 @@ async def async_setup(hass, config):
|
||||||
}
|
}
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=entry_config
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=entry_config,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from aiohttp.client_exceptions import ClientConnectionError, ClientResponseError
|
||||||
from pysmartapp.event import EVENT_TYPE_DEVICE
|
from pysmartapp.event import EVENT_TYPE_DEVICE
|
||||||
from pysmartthings import Attribute, Capability, SmartThings
|
from pysmartthings import Attribute, Capability, SmartThings
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ACCESS_TOKEN,
|
CONF_ACCESS_TOKEN,
|
||||||
CONF_CLIENT_ID,
|
CONF_CLIENT_ID,
|
||||||
|
@ -75,7 +75,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
if not [flow for flow in flows if flow["handler"] == DOMAIN]:
|
if not [flow for flow in flows if flow["handler"] == DOMAIN]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(DOMAIN, context={"source": "import"})
|
hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_IMPORT}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Return False because it could not be migrated.
|
# Return False because it could not be migrated.
|
||||||
|
@ -182,7 +184,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
if not [flow for flow in flows if flow["handler"] == DOMAIN]:
|
if not [flow for flow in flows if flow["handler"] == DOMAIN]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}
|
DOMAIN, context={"source": SOURCE_IMPORT}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -23,7 +23,7 @@ from zeroconf import (
|
||||||
Zeroconf,
|
Zeroconf,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant import util
|
from homeassistant import config_entries, util
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STARTED,
|
EVENT_HOMEASSISTANT_STARTED,
|
||||||
|
@ -401,7 +401,9 @@ def handle_homekit(
|
||||||
|
|
||||||
hass.add_job(
|
hass.add_job(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
homekit_models[test_model], context={"source": "homekit"}, data=info
|
homekit_models[test_model],
|
||||||
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
|
data=info,
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -7,7 +7,7 @@ from abodepy.helpers.errors import MFA_CODE_REQUIRED
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.abode import config_flow
|
from homeassistant.components.abode import config_flow
|
||||||
from homeassistant.components.abode.const import DOMAIN
|
from homeassistant.components.abode.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
@ -190,7 +190,7 @@ async def test_step_reauth(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth"},
|
context={"source": SOURCE_REAUTH},
|
||||||
data=conf,
|
data=conf,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data={"host": "mock-adguard", "port": "3000"},
|
data={"host": "mock-adguard", "port": "3000"},
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -111,7 +111,7 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": "3000"},
|
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": "3000"},
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -126,7 +126,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": "3000"},
|
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": "3000"},
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert "type" in result
|
assert "type" in result
|
||||||
|
@ -148,7 +148,7 @@ async def test_hassio_confirm(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": 3000},
|
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": 3000},
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
|
@ -176,7 +176,7 @@ async def test_hassio_connection_error(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": 3000},
|
data={"addon": "AdGuard Home Addon", "host": "mock-adguard", "port": 3000},
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
|
@ -19,7 +19,7 @@ from homeassistant.components.airvisual.const import (
|
||||||
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
||||||
INTEGRATION_TYPE_NODE_PRO,
|
INTEGRATION_TYPE_NODE_PRO,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_IP_ADDRESS,
|
CONF_IP_ADDRESS,
|
||||||
|
@ -349,7 +349,7 @@ async def test_step_reauth(hass):
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=entry_data
|
DOMAIN, context={"source": SOURCE_REAUTH}, data=entry_data
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ async def test_hassio(hass):
|
||||||
"""Test that Hass.io can discover this integration."""
|
"""Test that Hass.io can discover this integration."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
data={"addon": "Almond add-on", "host": "almond-addon", "port": "1234"},
|
data={"addon": "Almond add-on", "host": "almond-addon", "port": "1234"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ async def test_reconfigure_update_credentials(hass, mrp_device, pairing):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth"},
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
data={"identifier": "mrpid", "name": "apple tv"},
|
data={"identifier": "mrpid", "name": "apple tv"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -552,11 +552,11 @@ async def test_reconfigure_ongoing_aborts(hass, mrp_device):
|
||||||
}
|
}
|
||||||
|
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
|
@ -238,7 +238,7 @@ async def test_form_reauth(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -284,7 +284,7 @@ async def test_form_reauth_with_2fa(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
|
@ -6,7 +6,7 @@ from python_awair.exceptions import AuthError, AwairError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.awair.const import DOMAIN
|
from homeassistant.components.awair.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
|
||||||
from .const import CONFIG, DEVICES_FIXTURE, NO_DEVICES_FIXTURE, UNIQUE_ID, USER_FIXTURE
|
from .const import CONFIG, DEVICES_FIXTURE, NO_DEVICES_FIXTURE, UNIQUE_ID, USER_FIXTURE
|
||||||
|
@ -156,7 +156,7 @@ async def test_reauth(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "unique_id": UNIQUE_ID},
|
context={"source": SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
||||||
data=CONFIG,
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ async def test_reauth(hass):
|
||||||
with patch("python_awair.AwairClient.query", side_effect=AuthError()):
|
with patch("python_awair.AwairClient.query", side_effect=AuthError()):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "unique_id": UNIQUE_ID},
|
context={"source": SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
||||||
data=CONFIG,
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ async def test_reauth(hass):
|
||||||
with patch("python_awair.AwairClient.query", side_effect=AwairError()):
|
with patch("python_awair.AwairClient.query", side_effect=AwairError()):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "unique_id": UNIQUE_ID},
|
context={"source": SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
||||||
data=CONFIG,
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,9 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -110,7 +112,9 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
side_effect=aiohttp.ClientError,
|
side_effect=aiohttp.ClientError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -168,7 +172,9 @@ async def test_reauth_project_error(hass: HomeAssistant) -> None:
|
||||||
return_value=None,
|
return_value=None,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -197,7 +203,9 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
|
@ -246,7 +246,7 @@ async def test_form_unknown_error(hass):
|
||||||
async def test_reauth_shows_user_step(hass):
|
async def test_reauth_shows_user_step(hass):
|
||||||
"""Test reauth shows the user form."""
|
"""Test reauth shows the user form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
|
@ -30,7 +30,7 @@ FIXTURE_CONFIG_ENTRY = {
|
||||||
},
|
},
|
||||||
"options": {CONF_READ_ONLY: False, CONF_USE_LOCATION: False},
|
"options": {CONF_READ_ONLY: False, CONF_USE_LOCATION: False},
|
||||||
"system_options": {"disable_new_entities": False},
|
"system_options": {"disable_new_entities": False},
|
||||||
"source": "user",
|
"source": config_entries.SOURCE_USER,
|
||||||
"connection_class": config_entries.CONN_CLASS_CLOUD_POLL,
|
"connection_class": config_entries.CONN_CLASS_CLOUD_POLL,
|
||||||
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
|
"unique_id": f"{FIXTURE_USER_INPUT[CONF_REGION]}-{FIXTURE_USER_INPUT[CONF_REGION]}",
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,7 +733,7 @@ async def test_flow_reauth_works(hass):
|
||||||
|
|
||||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -769,7 +769,7 @@ async def test_flow_reauth_invalid_host(hass):
|
||||||
|
|
||||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
device.mac = get_device("Office").mac
|
device.mac = get_device("Office").mac
|
||||||
|
@ -803,7 +803,7 @@ async def test_flow_reauth_valid_host(hass):
|
||||||
|
|
||||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||||
)
|
)
|
||||||
|
|
||||||
device.host = "192.168.1.128"
|
device.host = "192.168.1.128"
|
||||||
|
@ -834,7 +834,7 @@ async def test_dhcp_can_finish(hass):
|
||||||
with patch(DEVICE_HELLO, return_value=mock_api):
|
with patch(DEVICE_HELLO, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -868,7 +868,7 @@ async def test_dhcp_fails_to_connect(hass):
|
||||||
with patch(DEVICE_HELLO, side_effect=blke.NetworkTimeoutError()):
|
with patch(DEVICE_HELLO, side_effect=blke.NetworkTimeoutError()):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -887,7 +887,7 @@ async def test_dhcp_unreachable(hass):
|
||||||
with patch(DEVICE_HELLO, side_effect=OSError(errno.ENETUNREACH, None)):
|
with patch(DEVICE_HELLO, side_effect=OSError(errno.ENETUNREACH, None)):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -906,7 +906,7 @@ async def test_dhcp_connect_unknown_error(hass):
|
||||||
with patch(DEVICE_HELLO, side_effect=OSError()):
|
with patch(DEVICE_HELLO, side_effect=OSError()):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -928,7 +928,7 @@ async def test_dhcp_device_not_supported(hass):
|
||||||
with patch(DEVICE_HELLO, return_value=mock_api):
|
with patch(DEVICE_HELLO, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: device.host,
|
IP_ADDRESS: device.host,
|
||||||
|
@ -952,7 +952,7 @@ async def test_dhcp_already_exists(hass):
|
||||||
with patch(DEVICE_HELLO, return_value=mock_api):
|
with patch(DEVICE_HELLO, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -978,7 +978,7 @@ async def test_dhcp_updates_host(hass):
|
||||||
with patch(DEVICE_HELLO, return_value=mock_api):
|
with patch(DEVICE_HELLO, return_value=mock_api):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "broadlink",
|
HOSTNAME: "broadlink",
|
||||||
IP_ADDRESS: "4.5.6.7",
|
IP_ADDRESS: "4.5.6.7",
|
||||||
|
|
|
@ -34,7 +34,14 @@ async def test_creating_entry_sets_up_media_player(hass):
|
||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("source", ["import", "user", "zeroconf"])
|
@pytest.mark.parametrize(
|
||||||
|
"source",
|
||||||
|
[
|
||||||
|
config_entries.SOURCE_IMPORT,
|
||||||
|
config_entries.SOURCE_USER,
|
||||||
|
config_entries.SOURCE_ZEROCONF,
|
||||||
|
],
|
||||||
|
)
|
||||||
async def test_single_instance(hass, source):
|
async def test_single_instance(hass, source):
|
||||||
"""Test we only allow a single config flow."""
|
"""Test we only allow a single config flow."""
|
||||||
MockConfigEntry(domain="cast").add_to_hass(hass)
|
MockConfigEntry(domain="cast").add_to_hass(hass)
|
||||||
|
@ -50,7 +57,7 @@ async def test_single_instance(hass, source):
|
||||||
async def test_user_setup(hass):
|
async def test_user_setup(hass):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"cast", context={"source": "user"}
|
"cast", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -70,7 +77,7 @@ async def test_user_setup(hass):
|
||||||
async def test_user_setup_options(hass):
|
async def test_user_setup_options(hass):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"cast", context={"source": "user"}
|
"cast", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -92,7 +99,7 @@ async def test_user_setup_options(hass):
|
||||||
async def test_zeroconf_setup(hass):
|
async def test_zeroconf_setup(hass):
|
||||||
"""Test we can finish a config flow through zeroconf."""
|
"""Test we can finish a config flow through zeroconf."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"cast", context={"source": "zeroconf"}
|
"cast", context={"source": config_entries.SOURCE_ZEROCONF}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -169,7 +176,7 @@ async def test_option_flow(hass, parameter_data):
|
||||||
orig_data = dict(config_entry.data)
|
orig_data = dict(config_entry.data)
|
||||||
|
|
||||||
# Reconfigure ignore_cec, known_hosts, uuid
|
# Reconfigure ignore_cec, known_hosts, uuid
|
||||||
context = {"source": "user", "show_advanced_options": True}
|
context = {"source": config_entries.SOURCE_USER, "show_advanced_options": True}
|
||||||
result = await hass.config_entries.options.async_init(
|
result = await hass.config_entries.options.async_init(
|
||||||
config_entry.entry_id, context=context
|
config_entry.entry_id, context=context
|
||||||
)
|
)
|
||||||
|
@ -213,7 +220,7 @@ async def test_option_flow(hass, parameter_data):
|
||||||
async def test_known_hosts(hass, castbrowser_mock, castbrowser_constructor_mock):
|
async def test_known_hosts(hass, castbrowser_mock, castbrowser_constructor_mock):
|
||||||
"""Test known hosts is passed to pychromecasts."""
|
"""Test known hosts is passed to pychromecasts."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"cast", context={"source": "user"}
|
"cast", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"known_hosts": "192.168.0.1, 192.168.0.2"}
|
result["flow_id"], {"known_hosts": "192.168.0.1, 192.168.0.2"}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import socket
|
||||||
import ssl
|
import ssl
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.cert_expiry.const import DEFAULT_PORT, DOMAIN
|
from homeassistant.components.cert_expiry.const import DEFAULT_PORT, DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry
|
||||||
async def test_user(hass):
|
async def test_user(hass):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -40,7 +40,7 @@ async def test_user(hass):
|
||||||
async def test_user_with_bad_cert(hass):
|
async def test_user_with_bad_cert(hass):
|
||||||
"""Test user config with bad certificate."""
|
"""Test user config with bad certificate."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -72,7 +72,9 @@ async def test_import_host_only(hass):
|
||||||
return_value=future_timestamp(1),
|
return_value=future_timestamp(1),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={CONF_HOST: HOST}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data={CONF_HOST: HOST},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ async def test_import_host_and_port(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={CONF_HOST: HOST, CONF_PORT: PORT},
|
data={CONF_HOST: HOST, CONF_PORT: PORT},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -114,7 +116,9 @@ async def test_import_non_default_port(hass):
|
||||||
return_value=future_timestamp(1),
|
return_value=future_timestamp(1),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={CONF_HOST: HOST, CONF_PORT: 888}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data={CONF_HOST: HOST, CONF_PORT: 888},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -135,7 +139,7 @@ async def test_import_with_name(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={CONF_NAME: "legacy", CONF_HOST: HOST, CONF_PORT: PORT},
|
data={CONF_NAME: "legacy", CONF_HOST: HOST, CONF_PORT: PORT},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -154,7 +158,9 @@ async def test_bad_import(hass):
|
||||||
side_effect=ConnectionRefusedError(),
|
side_effect=ConnectionRefusedError(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={CONF_HOST: HOST}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data={CONF_HOST: HOST},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
@ -170,13 +176,17 @@ async def test_abort_if_already_setup(hass):
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={CONF_HOST: HOST, CONF_PORT: PORT}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data={CONF_HOST: HOST, CONF_PORT: PORT},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data={CONF_HOST: HOST, CONF_PORT: PORT}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data={CONF_HOST: HOST, CONF_PORT: PORT},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -185,7 +195,7 @@ async def test_abort_if_already_setup(hass):
|
||||||
async def test_abort_on_socket_failed(hass):
|
async def test_abort_on_socket_failed(hass):
|
||||||
"""Test we abort of we have errors during socket creation."""
|
"""Test we abort of we have errors during socket creation."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
|
|
@ -330,7 +330,7 @@ async def test_create_account(hass, client):
|
||||||
"disabled_by": None,
|
"disabled_by": None,
|
||||||
"domain": "test",
|
"domain": "test",
|
||||||
"entry_id": entries[0].entry_id,
|
"entry_id": entries[0].entry_id,
|
||||||
"source": "user",
|
"source": core_ce.SOURCE_USER,
|
||||||
"state": "loaded",
|
"state": "loaded",
|
||||||
"supports_options": False,
|
"supports_options": False,
|
||||||
"supports_unload": False,
|
"supports_unload": False,
|
||||||
|
@ -401,7 +401,7 @@ async def test_two_step_flow(hass, client):
|
||||||
"disabled_by": None,
|
"disabled_by": None,
|
||||||
"domain": "test",
|
"domain": "test",
|
||||||
"entry_id": entries[0].entry_id,
|
"entry_id": entries[0].entry_id,
|
||||||
"source": "user",
|
"source": core_ce.SOURCE_USER,
|
||||||
"state": "loaded",
|
"state": "loaded",
|
||||||
"supports_options": False,
|
"supports_options": False,
|
||||||
"supports_unload": False,
|
"supports_unload": False,
|
||||||
|
@ -476,7 +476,7 @@ async def test_get_progress_index(hass, hass_ws_client):
|
||||||
|
|
||||||
with patch.dict(HANDLERS, {"test": TestFlow}):
|
with patch.dict(HANDLERS, {"test": TestFlow}):
|
||||||
form = await hass.config_entries.flow.async_init(
|
form = await hass.config_entries.flow.async_init(
|
||||||
"test", context={"source": "hassio"}
|
"test", context={"source": core_ce.SOURCE_HASSIO}
|
||||||
)
|
)
|
||||||
|
|
||||||
await ws_client.send_json({"id": 5, "type": "config_entries/flow/progress"})
|
await ws_client.send_json({"id": 5, "type": "config_entries/flow/progress"})
|
||||||
|
@ -488,7 +488,7 @@ async def test_get_progress_index(hass, hass_ws_client):
|
||||||
"flow_id": form["flow_id"],
|
"flow_id": form["flow_id"],
|
||||||
"handler": "test",
|
"handler": "test",
|
||||||
"step_id": "account",
|
"step_id": "account",
|
||||||
"context": {"source": "hassio"},
|
"context": {"source": core_ce.SOURCE_HASSIO},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ async def test_ignore_flow(hass, hass_ws_client):
|
||||||
|
|
||||||
with patch.dict(HANDLERS, {"test": TestFlow}):
|
with patch.dict(HANDLERS, {"test": TestFlow}):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"test", context={"source": "user"}
|
"test", context={"source": core_ce.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ from homeassistant.components.ssdp import (
|
||||||
ATTR_UPNP_UDN,
|
ATTR_UPNP_UDN,
|
||||||
)
|
)
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.config_entries import CONN_CLASS_LOCAL_PUSH, SOURCE_SSDP
|
from homeassistant.config_entries import CONN_CLASS_LOCAL_PUSH, SOURCE_SSDP, SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -109,7 +109,7 @@ async def setup_deconz_integration(
|
||||||
get_state_response=DECONZ_WEB_REQUEST,
|
get_state_response=DECONZ_WEB_REQUEST,
|
||||||
entry_id="1",
|
entry_id="1",
|
||||||
unique_id=BRIDGEID,
|
unique_id=BRIDGEID,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
):
|
):
|
||||||
"""Create the deCONZ gateway."""
|
"""Create the deCONZ gateway."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
|
|
|
@ -67,7 +67,8 @@ async def test_form_already_configured(hass):
|
||||||
async def test_form_advanced_options(hass):
|
async def test_form_advanced_options(hass):
|
||||||
"""Test if we get the advanced options if user has enabled it."""
|
"""Test if we get the advanced options if user has enabled it."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user", "show_advanced_options": True}
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
|
@ -7,6 +7,7 @@ from scapy.error import Scapy_Exception
|
||||||
from scapy.layers.dhcp import DHCP
|
from scapy.layers.dhcp import DHCP
|
||||||
from scapy.layers.l2 import Ether
|
from scapy.layers.l2 import Ether
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.components.device_tracker.const import (
|
from homeassistant.components.device_tracker.const import (
|
||||||
ATTR_HOST_NAME,
|
ATTR_HOST_NAME,
|
||||||
|
@ -98,7 +99,9 @@ async def test_dhcp_match_hostname_and_macaddress(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -123,7 +126,9 @@ async def test_dhcp_renewal_match_hostname_and_macaddress(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.1.120",
|
dhcp.IP_ADDRESS: "192.168.1.120",
|
||||||
dhcp.HOSTNAME: "irobot-ae9ec12dd3b04885bcbfa36afb01e1cc",
|
dhcp.HOSTNAME: "irobot-ae9ec12dd3b04885bcbfa36afb01e1cc",
|
||||||
|
@ -144,7 +149,9 @@ async def test_dhcp_match_hostname(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -165,7 +172,9 @@ async def test_dhcp_match_macaddress(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -435,7 +444,9 @@ async def test_device_tracker_hostname_and_macaddress_exists_before_start(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -470,7 +481,9 @@ async def test_device_tracker_hostname_and_macaddress_after_start(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -614,7 +627,9 @@ async def test_aiodiscover_finds_new_hosts(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
@ -667,14 +682,18 @@ async def test_aiodiscover_does_not_call_again_on_shorter_hostname(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 2
|
assert len(mock_init.mock_calls) == 2
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "irobot-abc",
|
dhcp.HOSTNAME: "irobot-abc",
|
||||||
dhcp.MAC_ADDRESS: "b8b7f16db533",
|
dhcp.MAC_ADDRESS: "b8b7f16db533",
|
||||||
}
|
}
|
||||||
assert mock_init.mock_calls[1][1][0] == "mock-domain"
|
assert mock_init.mock_calls[1][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[1][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[1][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[1][2]["data"] == {
|
assert mock_init.mock_calls[1][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "irobot-abcdef",
|
dhcp.HOSTNAME: "irobot-abcdef",
|
||||||
|
@ -715,7 +734,9 @@ async def test_aiodiscover_finds_new_hosts_after_interval(hass):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "dhcp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_DHCP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
dhcp.IP_ADDRESS: "192.168.210.56",
|
dhcp.IP_ADDRESS: "192.168.210.56",
|
||||||
dhcp.HOSTNAME: "connect",
|
dhcp.HOSTNAME: "connect",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import dialogflow, intent_script
|
from homeassistant.components import dialogflow, intent_script
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
@ -84,7 +84,7 @@ async def fixture(hass, aiohttp_client):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"dialogflow", context={"source": "user"}
|
"dialogflow", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
from voluptuous.error import MultipleInvalid
|
from voluptuous.error import MultipleInvalid
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.eafm import const
|
from homeassistant.components.eafm import const
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ async def test_flow_no_discovered_stations(hass, mock_get_stations):
|
||||||
"""Test config flow discovers no station."""
|
"""Test config flow discovers no station."""
|
||||||
mock_get_stations.return_value = []
|
mock_get_stations.return_value = []
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "no_stations"
|
assert result["reason"] == "no_stations"
|
||||||
|
@ -24,7 +25,7 @@ async def test_flow_invalid_station(hass, mock_get_stations):
|
||||||
]
|
]
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ async def test_flow_works(hass, mock_get_stations, mock_get_station):
|
||||||
]
|
]
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ async def test_dhcp_can_confirm(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "emonitor",
|
HOSTNAME: "emonitor",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -146,7 +146,7 @@ async def test_dhcp_fails_to_connect(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "emonitor",
|
HOSTNAME: "emonitor",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
@ -175,7 +175,7 @@ async def test_dhcp_already_exists(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "emonitor",
|
HOSTNAME: "emonitor",
|
||||||
IP_ADDRESS: "1.2.3.4",
|
IP_ADDRESS: "1.2.3.4",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Tests for EnOcean config flow."""
|
"""Tests for EnOcean config flow."""
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.enocean.config_flow import EnOceanFlowHandler
|
from homeassistant.components.enocean.config_flow import EnOceanFlowHandler
|
||||||
from homeassistant.components.enocean.const import DOMAIN
|
from homeassistant.components.enocean.const import DOMAIN
|
||||||
from homeassistant.const import CONF_DEVICE
|
from homeassistant.const import CONF_DEVICE
|
||||||
|
@ -21,7 +21,7 @@ async def test_user_flow_cannot_create_multiple_instances(hass):
|
||||||
|
|
||||||
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
|
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
@ -34,7 +34,7 @@ async def test_user_flow_with_detected_dongle(hass):
|
||||||
|
|
||||||
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[FAKE_DONGLE_PATH])):
|
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[FAKE_DONGLE_PATH])):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -48,7 +48,7 @@ async def test_user_flow_with_no_detected_dongle(hass):
|
||||||
"""Test the user flow with a detected ENOcean dongle."""
|
"""Test the user flow with a detected ENOcean dongle."""
|
||||||
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[])):
|
with patch(DONGLE_DETECT_METHOD, Mock(return_value=[])):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -141,7 +141,9 @@ async def test_import_flow_with_valid_path(hass):
|
||||||
|
|
||||||
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
|
with patch(DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=True)):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=DATA_TO_IMPORT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=DATA_TO_IMPORT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
@ -157,7 +159,9 @@ async def test_import_flow_with_invalid_path(hass):
|
||||||
Mock(return_value=False),
|
Mock(return_value=False),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=DATA_TO_IMPORT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=DATA_TO_IMPORT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
|
@ -130,7 +130,7 @@ async def test_import(hass: HomeAssistant) -> None:
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
"ip_address": "1.1.1.1",
|
"ip_address": "1.1.1.1",
|
||||||
"name": "Pool Envoy",
|
"name": "Pool Envoy",
|
||||||
|
@ -156,7 +156,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "zeroconf"},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data={
|
data={
|
||||||
"properties": {"serialnum": "1234"},
|
"properties": {"serialnum": "1234"},
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
|
@ -253,7 +253,7 @@ async def test_zeroconf_serial_already_exists(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "zeroconf"},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data={
|
data={
|
||||||
"properties": {"serialnum": "1234"},
|
"properties": {"serialnum": "1234"},
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
|
@ -288,7 +288,7 @@ async def test_zeroconf_host_already_exists(hass: HomeAssistant) -> None:
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "zeroconf"},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data={
|
data={
|
||||||
"properties": {"serialnum": "1234"},
|
"properties": {"serialnum": "1234"},
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.esphome import DOMAIN
|
from homeassistant.components.esphome import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
||||||
from homeassistant.data_entry_flow import (
|
from homeassistant.data_entry_flow import (
|
||||||
|
@ -51,7 +52,7 @@ async def test_user_connection_works(hass, mock_client):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data=None,
|
data=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ async def test_user_connection_works(hass, mock_client):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_HOST: "127.0.0.1", CONF_PORT: 80},
|
data={CONF_HOST: "127.0.0.1", CONF_PORT: 80},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ async def test_user_resolve_error(hass, mock_api_connection_error, mock_client):
|
||||||
mock_client.device_info.side_effect = exc
|
mock_client.device_info.side_effect = exc
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ async def test_user_connection_error(hass, mock_api_connection_error, mock_clien
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -133,7 +134,7 @@ async def test_user_with_password(hass, mock_client):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ async def test_user_invalid_password(hass, mock_api_connection_error, mock_clien
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome",
|
"esphome",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
data={CONF_HOST: "127.0.0.1", CONF_PORT: 6053},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ async def test_discovery_initiation(hass, mock_client):
|
||||||
"properties": {},
|
"properties": {},
|
||||||
}
|
}
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": "zeroconf"}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -220,7 +221,7 @@ async def test_discovery_already_configured_hostname(hass, mock_client):
|
||||||
"properties": {},
|
"properties": {},
|
||||||
}
|
}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": "zeroconf"}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
@ -245,7 +246,7 @@ async def test_discovery_already_configured_ip(hass, mock_client):
|
||||||
"properties": {"address": "192.168.43.183"},
|
"properties": {"address": "192.168.43.183"},
|
||||||
}
|
}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": "zeroconf"}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
@ -273,7 +274,7 @@ async def test_discovery_already_configured_name(hass, mock_client):
|
||||||
"properties": {"address": "test8266.local"},
|
"properties": {"address": "test8266.local"},
|
||||||
}
|
}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": "zeroconf"}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
@ -295,13 +296,13 @@ async def test_discovery_duplicate_data(hass, mock_client):
|
||||||
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(False, "test8266"))
|
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(False, "test8266"))
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", data=service_info, context={"source": "zeroconf"}
|
"esphome", data=service_info, context={"source": config_entries.SOURCE_ZEROCONF}
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_FORM
|
assert result["type"] == RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "discovery_confirm"
|
assert result["step_id"] == "discovery_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", data=service_info, context={"source": "zeroconf"}
|
"esphome", data=service_info, context={"source": config_entries.SOURCE_ZEROCONF}
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
@ -323,7 +324,7 @@ async def test_discovery_updates_unique_id(hass, mock_client):
|
||||||
"properties": {"address": "test8266.local"},
|
"properties": {"address": "test8266.local"},
|
||||||
}
|
}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": "zeroconf"}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == RESULT_TYPE_ABORT
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pyfireservicerota import InvalidAuthError
|
from pyfireservicerota import InvalidAuthError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.fireservicerota.const import DOMAIN
|
from homeassistant.components.fireservicerota.const import DOMAIN
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ MOCK_TOKEN_INFO = {
|
||||||
async def test_show_form(hass):
|
async def test_show_form(hass):
|
||||||
"""Test that the form is served with no input."""
|
"""Test that the form is served with no input."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -53,7 +53,7 @@ async def test_abort_if_already_setup(hass):
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -67,7 +67,7 @@ async def test_invalid_credentials(hass):
|
||||||
side_effect=InvalidAuthError,
|
side_effect=InvalidAuthError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ async def test_step_user(hass):
|
||||||
mock_fireservicerota.request_tokens.return_value = MOCK_TOKEN_INFO
|
mock_fireservicerota.request_tokens.return_value = MOCK_TOKEN_INFO
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -123,7 +123,10 @@ async def test_reauth(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "unique_id": entry.unique_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"unique_id": entry.unique_id,
|
||||||
|
},
|
||||||
data=MOCK_CONF,
|
data=MOCK_CONF,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,12 @@ from homeassistant.components.ssdp import (
|
||||||
ATTR_UPNP_FRIENDLY_NAME,
|
ATTR_UPNP_FRIENDLY_NAME,
|
||||||
ATTR_UPNP_UDN,
|
ATTR_UPNP_UDN,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_SSDP, SOURCE_USER
|
from homeassistant.config_entries import (
|
||||||
|
SOURCE_IMPORT,
|
||||||
|
SOURCE_REAUTH,
|
||||||
|
SOURCE_SSDP,
|
||||||
|
SOURCE_USER,
|
||||||
|
)
|
||||||
from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import (
|
from homeassistant.data_entry_flow import (
|
||||||
|
@ -182,7 +187,7 @@ async def test_reauth_not_successful(hass: HomeAssistant, fritz: Mock):
|
||||||
async def test_import(hass: HomeAssistant, fritz: Mock):
|
async def test_import(hass: HomeAssistant, fritz: Mock):
|
||||||
"""Test starting a flow by import."""
|
"""Test starting a flow by import."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "fake_host"
|
assert result["title"] == "fake_host"
|
||||||
|
|
|
@ -8,7 +8,7 @@ from garminconnect import (
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.garmin_connect.const import DOMAIN
|
from homeassistant.components.garmin_connect.const import DOMAIN
|
||||||
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def mock_garmin():
|
||||||
async def test_show_form(hass):
|
async def test_show_form(hass):
|
||||||
"""Test that the form is served with no input."""
|
"""Test that the form is served with no input."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -47,7 +47,7 @@ async def test_step_user(hass, mock_garmin_connect):
|
||||||
"homeassistant.components.garmin_connect.async_setup_entry", return_value=True
|
"homeassistant.components.garmin_connect.async_setup_entry", return_value=True
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["data"] == MOCK_CONF
|
assert result["data"] == MOCK_CONF
|
||||||
|
@ -57,7 +57,7 @@ async def test_connection_error(hass, mock_garmin_connect):
|
||||||
"""Test for connection error."""
|
"""Test for connection error."""
|
||||||
mock_garmin_connect.login.side_effect = GarminConnectConnectionError("errormsg")
|
mock_garmin_connect.login.side_effect = GarminConnectConnectionError("errormsg")
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
@ -67,7 +67,7 @@ async def test_authentication_error(hass, mock_garmin_connect):
|
||||||
"""Test for authentication error."""
|
"""Test for authentication error."""
|
||||||
mock_garmin_connect.login.side_effect = GarminConnectAuthenticationError("errormsg")
|
mock_garmin_connect.login.side_effect = GarminConnectAuthenticationError("errormsg")
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
@ -79,7 +79,7 @@ async def test_toomanyrequest_error(hass, mock_garmin_connect):
|
||||||
"errormsg"
|
"errormsg"
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["errors"] == {"base": "too_many_requests"}
|
assert result["errors"] == {"base": "too_many_requests"}
|
||||||
|
@ -89,7 +89,7 @@ async def test_unknown_error(hass, mock_garmin_connect):
|
||||||
"""Test for unknown error."""
|
"""Test for unknown error."""
|
||||||
mock_garmin_connect.login.side_effect = Exception
|
mock_garmin_connect.login.side_effect = Exception
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
@ -100,7 +100,7 @@ async def test_abort_if_already_setup(hass, mock_garmin_connect):
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONF, unique_id=MOCK_CONF[CONF_ID])
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONF, unique_id=MOCK_CONF[CONF_ID])
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_CONF
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_CONF
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.gdacs import CONF_CATEGORIES, DOMAIN
|
from homeassistant.components.gdacs import CONF_CATEGORIES, DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_LATITUDE,
|
CONF_LATITUDE,
|
||||||
|
@ -27,7 +27,7 @@ async def test_duplicate_error(hass, config_entry):
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -36,7 +36,7 @@ async def test_duplicate_error(hass, config_entry):
|
||||||
async def test_show_form(hass):
|
async def test_show_form(hass):
|
||||||
"""Test that the form is served with no input."""
|
"""Test that the form is served with no input."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -53,7 +53,7 @@ async def test_step_import(hass):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "-41.2, 174.7"
|
assert result["title"] == "-41.2, 174.7"
|
||||||
|
@ -73,7 +73,7 @@ async def test_step_user(hass):
|
||||||
conf = {CONF_RADIUS: 25}
|
conf = {CONF_RADIUS: 25}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "-41.2, 174.7"
|
assert result["title"] == "-41.2, 174.7"
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import zone
|
from homeassistant.components import zone
|
||||||
from homeassistant.components.geofency import CONF_MOBILE_BEACONS, DOMAIN
|
from homeassistant.components.geofency import CONF_MOBILE_BEACONS, DOMAIN
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
|
@ -157,7 +157,7 @@ async def webhook_id(hass, geofency_client):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.geonetnz_quakes import (
|
from homeassistant.components.geonetnz_quakes import (
|
||||||
CONF_MINIMUM_MAGNITUDE,
|
CONF_MINIMUM_MAGNITUDE,
|
||||||
CONF_MMI,
|
CONF_MMI,
|
||||||
|
@ -23,7 +23,7 @@ async def test_duplicate_error(hass, config_entry):
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -32,7 +32,7 @@ async def test_duplicate_error(hass, config_entry):
|
||||||
async def test_show_form(hass):
|
async def test_show_form(hass):
|
||||||
"""Test that the form is served with no input."""
|
"""Test that the form is served with no input."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -54,7 +54,7 @@ async def test_step_import(hass):
|
||||||
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
|
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
|
||||||
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
|
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "-41.2, 174.7"
|
assert result["title"] == "-41.2, 174.7"
|
||||||
|
@ -79,7 +79,7 @@ async def test_step_user(hass):
|
||||||
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
|
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
|
||||||
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
|
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "-41.2, 174.7"
|
assert result["title"] == "-41.2, 174.7"
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from glances_api import Glances
|
from glances_api import Glances
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import glances
|
from homeassistant.components import glances
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_SCAN_INTERVAL
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ async def test_form(hass):
|
||||||
"""Test config entry configured successfully."""
|
"""Test config entry configured successfully."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
glances.DOMAIN, context={"source": "user"}
|
glances.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -56,7 +56,7 @@ async def test_form_cannot_connect(hass):
|
||||||
|
|
||||||
with patch("glances_api.Glances"):
|
with patch("glances_api.Glances"):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
glances.DOMAIN, context={"source": "user"}
|
glances.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
|
@ -72,7 +72,7 @@ async def test_form_wrong_version(hass):
|
||||||
user_input = DEMO_USER_INPUT.copy()
|
user_input = DEMO_USER_INPUT.copy()
|
||||||
user_input.update(version=1)
|
user_input.update(version=1)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
glances.DOMAIN, context={"source": "user"}
|
glances.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=user_input
|
result["flow_id"], user_input=user_input
|
||||||
|
@ -90,7 +90,7 @@ async def test_form_already_configured(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
glances.DOMAIN, context={"source": "user"}
|
glances.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import gpslogger, zone
|
from homeassistant.components import gpslogger, zone
|
||||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||||
from homeassistant.components.gpslogger import DOMAIN, TRACKER_UPDATE
|
from homeassistant.components.gpslogger import DOMAIN, TRACKER_UPDATE
|
||||||
|
@ -69,7 +69,7 @@ async def webhook_id(hass, gpslogger_client):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant import data_entry_flow
|
||||||
from homeassistant.components import heos, ssdp
|
from homeassistant.components import heos, ssdp
|
||||||
from homeassistant.components.heos.config_flow import HeosFlowHandler
|
from homeassistant.components.heos.config_flow import HeosFlowHandler
|
||||||
from homeassistant.components.heos.const import DATA_DISCOVERED_HOSTS, DOMAIN
|
from homeassistant.components.heos.const import DATA_DISCOVERED_HOSTS, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_SSDP
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_SSDP, SOURCE_USER
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ async def test_cannot_connect_shows_error_form(hass, controller):
|
||||||
"""Test form is shown with error when cannot connect."""
|
"""Test form is shown with error when cannot connect."""
|
||||||
controller.connect.side_effect = HeosError()
|
controller.connect.side_effect = HeosError()
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
heos.DOMAIN, context={"source": "user"}, data={CONF_HOST: "127.0.0.1"}
|
heos.DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "127.0.0.1"}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -52,7 +52,7 @@ async def test_create_entry_when_host_valid(hass, controller):
|
||||||
data = {CONF_HOST: "127.0.0.1"}
|
data = {CONF_HOST: "127.0.0.1"}
|
||||||
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
heos.DOMAIN, context={"source": "user"}, data=data
|
heos.DOMAIN, context={"source": SOURCE_USER}, data=data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["result"].unique_id == DOMAIN
|
assert result["result"].unique_id == DOMAIN
|
||||||
|
@ -68,7 +68,7 @@ async def test_create_entry_when_friendly_name_valid(hass, controller):
|
||||||
data = {CONF_HOST: "Office (127.0.0.1)"}
|
data = {CONF_HOST: "Office (127.0.0.1)"}
|
||||||
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.heos.async_setup_entry", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
heos.DOMAIN, context={"source": "user"}, data=data
|
heos.DOMAIN, context={"source": SOURCE_USER}, data=data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["result"].unique_id == DOMAIN
|
assert result["result"].unique_id == DOMAIN
|
||||||
|
@ -83,7 +83,7 @@ async def test_discovery_shows_create_form(hass, controller, discovery_data):
|
||||||
"""Test discovery shows form to confirm setup and subsequent abort."""
|
"""Test discovery shows form to confirm setup and subsequent abort."""
|
||||||
|
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
heos.DOMAIN, context={"source": "ssdp"}, data=discovery_data
|
heos.DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_data
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
flows_in_progress = hass.config_entries.flow.async_progress()
|
flows_in_progress = hass.config_entries.flow.async_progress()
|
||||||
|
@ -96,7 +96,7 @@ async def test_discovery_shows_create_form(hass, controller, discovery_data):
|
||||||
discovery_data[ssdp.ATTR_UPNP_FRIENDLY_NAME] = "Bedroom"
|
discovery_data[ssdp.ATTR_UPNP_FRIENDLY_NAME] = "Bedroom"
|
||||||
|
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
heos.DOMAIN, context={"source": "ssdp"}, data=discovery_data
|
heos.DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_data
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
flows_in_progress = hass.config_entries.flow.async_progress()
|
flows_in_progress = hass.config_entries.flow.async_progress()
|
||||||
|
|
|
@ -9,6 +9,7 @@ from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.homekit_controller import config_flow
|
from homeassistant.components.homekit_controller import config_flow
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
|
||||||
|
@ -177,13 +178,15 @@ async def test_discovery_works(hass, controller, upper_case_props, missing_cshar
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "pair"
|
assert result["step_id"] == "pair"
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
}
|
}
|
||||||
|
@ -209,13 +212,17 @@ async def test_abort_duplicate_flow(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "pair"
|
assert result["step_id"] == "pair"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
@ -231,7 +238,9 @@ async def test_pair_already_paired_1(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_paired"
|
assert result["reason"] == "already_paired"
|
||||||
|
@ -247,7 +256,9 @@ async def test_id_missing(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "invalid_properties"
|
assert result["reason"] == "invalid_properties"
|
||||||
|
@ -262,7 +273,9 @@ async def test_discovery_ignored_model(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "ignored_model"
|
assert result["reason"] == "ignored_model"
|
||||||
|
@ -287,7 +300,9 @@ async def test_discovery_ignored_hk_bridge(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "ignored_model"
|
assert result["reason"] == "ignored_model"
|
||||||
|
@ -312,7 +327,9 @@ async def test_discovery_does_not_ignore_non_homekit(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -333,7 +350,9 @@ async def test_discovery_invalid_config_entry(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Discovery of a HKID that is in a pairable state but for which there is
|
# Discovery of a HKID that is in a pairable state but for which there is
|
||||||
|
@ -362,7 +381,9 @@ async def test_discovery_already_configured(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -377,7 +398,9 @@ async def test_pair_abort_errors_on_start(hass, controller, exception, expected)
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
# User initiates pairing - device refuses to enter pairing mode
|
# User initiates pairing - device refuses to enter pairing mode
|
||||||
|
@ -397,7 +420,9 @@ async def test_pair_try_later_errors_on_start(hass, controller, exception, expec
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
# User initiates pairing - device refuses to enter pairing mode but may be successful after entering pairing mode or rebooting
|
# User initiates pairing - device refuses to enter pairing mode but may be successful after entering pairing mode or rebooting
|
||||||
|
@ -432,14 +457,16 @@ async def test_pair_form_errors_on_start(hass, controller, exception, expected):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User initiates pairing - device refuses to enter pairing mode
|
# User initiates pairing - device refuses to enter pairing mode
|
||||||
|
@ -455,7 +482,7 @@ async def test_pair_form_errors_on_start(hass, controller, exception, expected):
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User gets back the form
|
# User gets back the form
|
||||||
|
@ -480,14 +507,16 @@ async def test_pair_abort_errors_on_finish(hass, controller, exception, expected
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User initiates pairing - this triggers the device to show a pairing code
|
# User initiates pairing - this triggers the device to show a pairing code
|
||||||
|
@ -501,7 +530,7 @@ async def test_pair_abort_errors_on_finish(hass, controller, exception, expected
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User enters pairing code
|
# User enters pairing code
|
||||||
|
@ -520,14 +549,16 @@ async def test_pair_form_errors_on_finish(hass, controller, exception, expected)
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "zeroconf"}, data=discovery_info
|
"homekit_controller",
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User initiates pairing - this triggers the device to show a pairing code
|
# User initiates pairing - this triggers the device to show a pairing code
|
||||||
|
@ -541,7 +572,7 @@ async def test_pair_form_errors_on_finish(hass, controller, exception, expected)
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User enters pairing code
|
# User enters pairing code
|
||||||
|
@ -555,7 +586,7 @@ async def test_pair_form_errors_on_finish(hass, controller, exception, expected)
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "zeroconf",
|
"source": config_entries.SOURCE_ZEROCONF,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,13 +596,13 @@ async def test_user_works(hass, controller):
|
||||||
|
|
||||||
# Device is discovered
|
# Device is discovered
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "user"}
|
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"source": "user",
|
"source": config_entries.SOURCE_USER,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -581,7 +612,7 @@ async def test_user_works(hass, controller):
|
||||||
assert result["step_id"] == "pair"
|
assert result["step_id"] == "pair"
|
||||||
|
|
||||||
assert get_flow_context(hass, result) == {
|
assert get_flow_context(hass, result) == {
|
||||||
"source": "user",
|
"source": config_entries.SOURCE_USER,
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
}
|
}
|
||||||
|
@ -596,7 +627,7 @@ async def test_user_works(hass, controller):
|
||||||
async def test_user_no_devices(hass, controller):
|
async def test_user_no_devices(hass, controller):
|
||||||
"""Test user initiated pairing where no devices discovered."""
|
"""Test user initiated pairing where no devices discovered."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "user"}
|
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "no_devices"
|
assert result["reason"] == "no_devices"
|
||||||
|
@ -612,7 +643,7 @@ async def test_user_no_unpaired_devices(hass, controller):
|
||||||
|
|
||||||
# Device discovery is requested
|
# Device discovery is requested
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller", context={"source": "user"}
|
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -626,7 +657,7 @@ async def test_unignore_works(hass, controller):
|
||||||
# Device is unignored
|
# Device is unignored
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller",
|
"homekit_controller",
|
||||||
context={"source": "unignore"},
|
context={"source": config_entries.SOURCE_UNIGNORE},
|
||||||
data={"unique_id": device.device_id},
|
data={"unique_id": device.device_id},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -635,7 +666,7 @@ async def test_unignore_works(hass, controller):
|
||||||
"hkid": "00:00:00:00:00:00",
|
"hkid": "00:00:00:00:00:00",
|
||||||
"title_placeholders": {"name": "TestDevice"},
|
"title_placeholders": {"name": "TestDevice"},
|
||||||
"unique_id": "00:00:00:00:00:00",
|
"unique_id": "00:00:00:00:00:00",
|
||||||
"source": "unignore",
|
"source": config_entries.SOURCE_UNIGNORE,
|
||||||
}
|
}
|
||||||
|
|
||||||
# User initiates pairing by clicking on 'configure' - device enters pairing mode and displays code
|
# User initiates pairing by clicking on 'configure' - device enters pairing mode and displays code
|
||||||
|
@ -658,7 +689,7 @@ async def test_unignore_ignores_missing_devices(hass, controller):
|
||||||
# Device is unignored
|
# Device is unignored
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"homekit_controller",
|
"homekit_controller",
|
||||||
context={"source": "unignore"},
|
context={"source": config_entries.SOURCE_UNIGNORE},
|
||||||
data={"unique_id": "00:00:00:00:00:01"},
|
data={"unique_id": "00:00:00:00:00:01"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Tests for HomematicIP Cloud config flow."""
|
"""Tests for HomematicIP Cloud config flow."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.homematicip_cloud.const import (
|
from homeassistant.components.homematicip_cloud.const import (
|
||||||
DOMAIN as HMIPC_DOMAIN,
|
DOMAIN as HMIPC_DOMAIN,
|
||||||
HMIPC_AUTHTOKEN,
|
HMIPC_AUTHTOKEN,
|
||||||
|
@ -27,7 +28,9 @@ async def test_flow_works(hass, simple_mock_home):
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}, data=DEFAULT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=DEFAULT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -70,7 +73,9 @@ async def test_flow_init_connection_error(hass):
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}, data=DEFAULT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=DEFAULT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -90,7 +95,9 @@ async def test_flow_link_connection_error(hass):
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}, data=DEFAULT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=DEFAULT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -107,7 +114,9 @@ async def test_flow_link_press_button(hass):
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}, data=DEFAULT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=DEFAULT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -119,7 +128,7 @@ async def test_init_flow_show_form(hass):
|
||||||
"""Test config flow shows up with a form."""
|
"""Test config flow shows up with a form."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}
|
HMIPC_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
@ -133,7 +142,9 @@ async def test_init_already_configured(hass):
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "user"}, data=DEFAULT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=DEFAULT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -155,7 +166,9 @@ async def test_import_config(hass, simple_mock_home):
|
||||||
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
|
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "import"}, data=IMPORT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=IMPORT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
@ -178,7 +191,9 @@ async def test_import_existing_config(hass):
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
HMIPC_DOMAIN, context={"source": "import"}, data=IMPORT_CONFIG
|
HMIPC_DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=IMPORT_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -54,7 +54,7 @@ async def test_flow_works(hass):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -101,7 +101,7 @@ async def test_manual_flow_works(hass, aioclient_mock):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -157,7 +157,7 @@ async def test_manual_flow_bridge_exist(hass, aioclient_mock):
|
||||||
return_value=[],
|
return_value=[],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -184,7 +184,7 @@ async def test_manual_flow_no_discovered_bridges(hass, aioclient_mock):
|
||||||
aioclient_mock.get(URL_NUPNP, json=[])
|
aioclient_mock.get(URL_NUPNP, json=[])
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "manual"
|
assert result["step_id"] == "manual"
|
||||||
|
@ -198,7 +198,7 @@ async def test_flow_all_discovered_bridges_exist(hass, aioclient_mock):
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -221,7 +221,7 @@ async def test_flow_bridges_discovered(hass, aioclient_mock):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
@ -248,7 +248,7 @@ async def test_flow_two_bridges_discovered_one_new(hass, aioclient_mock):
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -266,7 +266,7 @@ async def test_flow_timeout_discovery(hass):
|
||||||
side_effect=asyncio.TimeoutError,
|
side_effect=asyncio.TimeoutError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -283,7 +283,7 @@ async def test_flow_link_timeout(hass):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -308,7 +308,7 @@ async def test_flow_link_unknown_error(hass):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -334,7 +334,7 @@ async def test_flow_link_button_not_pressed(hass):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -360,7 +360,7 @@ async def test_flow_link_unknown_host(hass):
|
||||||
return_value=[mock_bridge],
|
return_value=[mock_bridge],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "user"}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -380,7 +380,7 @@ async def test_bridge_ssdp(hass, mf_url):
|
||||||
"""Test a bridge being discovered."""
|
"""Test a bridge being discovered."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: mf_url,
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: mf_url,
|
||||||
|
@ -396,7 +396,7 @@ async def test_bridge_ssdp_discover_other_bridge(hass):
|
||||||
"""Test that discovery ignores other bridges."""
|
"""Test that discovery ignores other bridges."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={ssdp.ATTR_UPNP_MANUFACTURER_URL: "http://www.notphilips.com"},
|
data={ssdp.ATTR_UPNP_MANUFACTURER_URL: "http://www.notphilips.com"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ async def test_bridge_ssdp_emulated_hue(hass):
|
||||||
"""Test if discovery info is from an emulated hue instance."""
|
"""Test if discovery info is from an emulated hue instance."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Home Assistant Bridge",
|
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Home Assistant Bridge",
|
||||||
|
@ -425,7 +425,7 @@ async def test_bridge_ssdp_missing_location(hass):
|
||||||
"""Test if discovery info is missing a location attribute."""
|
"""Test if discovery info is missing a location attribute."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||||
ssdp.ATTR_UPNP_SERIAL: "1234",
|
ssdp.ATTR_UPNP_SERIAL: "1234",
|
||||||
|
@ -440,7 +440,7 @@ async def test_bridge_ssdp_missing_serial(hass):
|
||||||
"""Test if discovery info is a serial attribute."""
|
"""Test if discovery info is a serial attribute."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||||
|
@ -455,7 +455,7 @@ async def test_bridge_ssdp_espalexa(hass):
|
||||||
"""Test if discovery info is from an Espalexa based device."""
|
"""Test if discovery info is from an Espalexa based device."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Espalexa (0.0.0.0)",
|
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Espalexa (0.0.0.0)",
|
||||||
|
@ -476,7 +476,7 @@ async def test_bridge_ssdp_already_configured(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||||
|
@ -492,7 +492,7 @@ async def test_import_with_no_config(hass):
|
||||||
"""Test importing a host without an existing config file."""
|
"""Test importing a host without an existing config file."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "0.0.0.0"},
|
data={"host": "0.0.0.0"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -531,7 +531,9 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass):
|
||||||
return_value=bridge,
|
return_value=bridge,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"hue", data={"host": "2.2.2.2"}, context={"source": "import"}
|
"hue",
|
||||||
|
data={"host": "2.2.2.2"},
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -561,7 +563,7 @@ async def test_bridge_homekit(hass, aioclient_mock):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={
|
data={
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"serial": "1234",
|
"serial": "1234",
|
||||||
|
@ -589,7 +591,7 @@ async def test_bridge_import_already_configured(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -605,7 +607,7 @@ async def test_bridge_homekit_already_configured(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -622,7 +624,7 @@ async def test_ssdp_discovery_update_configuration(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN,
|
const.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
ssdp.ATTR_SSDP_LOCATION: "http://1.1.1.1/",
|
ssdp.ATTR_SSDP_LOCATION: "http://1.1.1.1/",
|
||||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||||
|
|
|
@ -69,7 +69,9 @@ async def test_form_homekit(hass):
|
||||||
"""Test we get the form with homekit source."""
|
"""Test we get the form with homekit source."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
ignored_config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
|
ignored_config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
ignored_config_entry.add_to_hass(hass)
|
ignored_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
mock_powerview_userdata = _get_mock_powerview_userdata()
|
mock_powerview_userdata = _get_mock_powerview_userdata()
|
||||||
|
@ -79,7 +81,7 @@ async def test_form_homekit(hass):
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={
|
data={
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
||||||
|
@ -114,7 +116,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_init(
|
result3 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={
|
data={
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
||||||
|
|
|
@ -255,7 +255,7 @@ async def test_options_flow(hass):
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
title="Wartenau",
|
title="Wartenau",
|
||||||
data=FIXTURE_CONFIG_ENTRY,
|
data=FIXTURE_CONFIG_ENTRY,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
connection_class=CONN_CLASS_CLOUD_POLL,
|
connection_class=CONN_CLASS_CLOUD_POLL,
|
||||||
system_options={"disable_new_entities": False},
|
system_options={"disable_new_entities": False},
|
||||||
options=FIXTURE_OPTIONS,
|
options=FIXTURE_OPTIONS,
|
||||||
|
@ -306,7 +306,7 @@ async def test_options_flow_invalid_auth(hass):
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
title="Wartenau",
|
title="Wartenau",
|
||||||
data=FIXTURE_CONFIG_ENTRY,
|
data=FIXTURE_CONFIG_ENTRY,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
connection_class=CONN_CLASS_CLOUD_POLL,
|
connection_class=CONN_CLASS_CLOUD_POLL,
|
||||||
system_options={"disable_new_entities": False},
|
system_options={"disable_new_entities": False},
|
||||||
options=FIXTURE_OPTIONS,
|
options=FIXTURE_OPTIONS,
|
||||||
|
@ -347,7 +347,7 @@ async def test_options_flow_cannot_connect(hass):
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
title="Wartenau",
|
title="Wartenau",
|
||||||
data=FIXTURE_CONFIG_ENTRY,
|
data=FIXTURE_CONFIG_ENTRY,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
connection_class=CONN_CLASS_CLOUD_POLL,
|
connection_class=CONN_CLASS_CLOUD_POLL,
|
||||||
system_options={"disable_new_entities": False},
|
system_options={"disable_new_entities": False},
|
||||||
options=FIXTURE_OPTIONS,
|
options=FIXTURE_OPTIONS,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Test the init file of IFTTT."""
|
"""Test the init file of IFTTT."""
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import ifttt
|
from homeassistant.components import ifttt
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
@ -13,7 +13,7 @@ async def test_config_flow_registers_webhook(hass, aiohttp_client):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"ifttt", context={"source": "user"}
|
"ifttt", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import islamic_prayer_times
|
from homeassistant.components import islamic_prayer_times
|
||||||
from homeassistant.components.islamic_prayer_times.const import CONF_CALC_METHOD, DOMAIN
|
from homeassistant.components.islamic_prayer_times.const import CONF_CALC_METHOD, DOMAIN
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def mock_setup():
|
||||||
async def test_flow_works(hass):
|
async def test_flow_works(hass):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
islamic_prayer_times.DOMAIN, context={"source": "user"}
|
islamic_prayer_times.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -62,7 +62,7 @@ async def test_import(hass):
|
||||||
"""Test import step."""
|
"""Test import step."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
islamic_prayer_times.DOMAIN,
|
islamic_prayer_times.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={CONF_CALC_METHOD: "makkah"},
|
data={CONF_CALC_METHOD: "makkah"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ async def test_integration_already_configured(hass):
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
islamic_prayer_times.DOMAIN, context={"source": "user"}
|
islamic_prayer_times.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
|
@ -136,7 +136,7 @@ async def test_host_already_configured(hass, connect):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
keenetic.DOMAIN, context={"source": "user"}
|
keenetic.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -151,7 +151,7 @@ async def test_connection_error(hass, connect_error):
|
||||||
"""Test error when connection is unsuccessful."""
|
"""Test error when connection is unsuccessful."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
keenetic.DOMAIN, context={"source": "user"}
|
keenetic.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=MOCK_DATA
|
result["flow_id"], user_input=MOCK_DATA
|
||||||
|
|
|
@ -411,7 +411,9 @@ async def test_discovery(hass):
|
||||||
return_value=MockConnection(),
|
return_value=MockConnection(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -450,7 +452,9 @@ async def test_discovery_cannot_connect_http(hass):
|
||||||
return_value=MockConnection(),
|
return_value=MockConnection(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -471,7 +475,9 @@ async def test_discovery_cannot_connect_ws(hass):
|
||||||
new=get_kodi_connection,
|
new=get_kodi_connection,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -489,7 +495,9 @@ async def test_discovery_exception_http(hass, user_flow):
|
||||||
return_value=MockConnection(),
|
return_value=MockConnection(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -506,7 +514,9 @@ async def test_discovery_invalid_auth(hass):
|
||||||
return_value=MockConnection(),
|
return_value=MockConnection(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -524,14 +534,16 @@ async def test_discovery_duplicate_data(hass):
|
||||||
return_value=MockConnection(),
|
return_value=MockConnection(),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "discovery_confirm"
|
assert result["step_id"] == "discovery_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -549,7 +561,7 @@ async def test_discovery_updates_unique_id(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -563,7 +575,9 @@ async def test_discovery_updates_unique_id(hass):
|
||||||
async def test_discovery_without_unique_id(hass):
|
async def test_discovery_without_unique_id(hass):
|
||||||
"""Test a discovery flow with no unique id aborts."""
|
"""Test a discovery flow with no unique id aborts."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY_WO_UUID
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY_WO_UUID,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import konnected
|
from homeassistant.components import konnected
|
||||||
from homeassistant.components.konnected import config_flow
|
from homeassistant.components.konnected import config_flow
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ async def mock_panel_fixture():
|
||||||
async def test_flow_works(hass, mock_panel):
|
async def test_flow_works(hass, mock_panel):
|
||||||
"""Test config flow ."""
|
"""Test config flow ."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -65,7 +66,7 @@ async def test_flow_works(hass, mock_panel):
|
||||||
async def test_pro_flow_works(hass, mock_panel):
|
async def test_pro_flow_works(hass, mock_panel):
|
||||||
"""Test config flow ."""
|
"""Test config flow ."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -110,7 +111,7 @@ async def test_ssdp(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
"ssdp_location": "http://1.2.3.4:1234/Device.xml",
|
"ssdp_location": "http://1.2.3.4:1234/Device.xml",
|
||||||
"manufacturer": config_flow.KONN_MANUFACTURER,
|
"manufacturer": config_flow.KONN_MANUFACTURER,
|
||||||
|
@ -137,7 +138,7 @@ async def test_import_no_host_user_finish(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
"default_options": {
|
"default_options": {
|
||||||
"blink": True,
|
"blink": True,
|
||||||
|
@ -204,7 +205,7 @@ async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
"default_options": {
|
"default_options": {
|
||||||
"blink": True,
|
"blink": True,
|
||||||
|
@ -238,7 +239,7 @@ async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
||||||
# discover the panel via ssdp
|
# discover the panel via ssdp
|
||||||
ssdp_result = await hass.config_entries.flow.async_init(
|
ssdp_result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
"ssdp_location": "http://0.0.0.0:1234/Device.xml",
|
"ssdp_location": "http://0.0.0.0:1234/Device.xml",
|
||||||
"manufacturer": config_flow.KONN_MANUFACTURER,
|
"manufacturer": config_flow.KONN_MANUFACTURER,
|
||||||
|
@ -281,7 +282,7 @@ async def test_ssdp_already_configured(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
"ssdp_location": "http://0.0.0.0:1234/Device.xml",
|
"ssdp_location": "http://0.0.0.0:1234/Device.xml",
|
||||||
"manufacturer": config_flow.KONN_MANUFACTURER,
|
"manufacturer": config_flow.KONN_MANUFACTURER,
|
||||||
|
@ -357,7 +358,7 @@ async def test_ssdp_host_update(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "ssdp"},
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
data={
|
data={
|
||||||
"ssdp_location": "http://1.1.1.1:1234/Device.xml",
|
"ssdp_location": "http://1.1.1.1:1234/Device.xml",
|
||||||
"manufacturer": config_flow.KONN_MANUFACTURER,
|
"manufacturer": config_flow.KONN_MANUFACTURER,
|
||||||
|
@ -382,7 +383,7 @@ async def test_import_existing_config(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data=konnected.DEVICE_SCHEMA_YAML(
|
data=konnected.DEVICE_SCHEMA_YAML(
|
||||||
{
|
{
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
|
@ -515,7 +516,7 @@ async def test_import_existing_config_entry(hass, mock_panel):
|
||||||
hass.data[config_flow.DOMAIN] = {"access_token": "SUPERSECRETTOKEN"}
|
hass.data[config_flow.DOMAIN] = {"access_token": "SUPERSECRETTOKEN"}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
"port": 1234,
|
"port": 1234,
|
||||||
|
@ -573,7 +574,7 @@ async def test_import_pin_config(hass, mock_panel):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data=konnected.DEVICE_SCHEMA_YAML(
|
data=konnected.DEVICE_SCHEMA_YAML(
|
||||||
{
|
{
|
||||||
"host": "1.2.3.4",
|
"host": "1.2.3.4",
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.litejet.const import DOMAIN
|
from homeassistant.components.litejet.const import DOMAIN
|
||||||
from homeassistant.const import CONF_PORT
|
from homeassistant.const import CONF_PORT
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ from tests.common import MockConfigEntry
|
||||||
async def test_show_config_form(hass):
|
async def test_show_config_form(hass):
|
||||||
"""Test show configuration form."""
|
"""Test show configuration form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -24,7 +25,7 @@ async def test_create_entry(hass, mock_litejet):
|
||||||
test_data = {CONF_PORT: "/dev/test"}
|
test_data = {CONF_PORT: "/dev/test"}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
@ -43,7 +44,7 @@ async def test_flow_entry_already_exists(hass):
|
||||||
test_data = {CONF_PORT: "/dev/test"}
|
test_data = {CONF_PORT: "/dev/test"}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -58,7 +59,7 @@ async def test_flow_open_failed(hass):
|
||||||
mock_pylitejet.side_effect = SerialException
|
mock_pylitejet.side_effect = SerialException
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -69,7 +70,7 @@ async def test_import_step(hass):
|
||||||
"""Test initializing via import step."""
|
"""Test initializing via import step."""
|
||||||
test_data = {CONF_PORT: "/dev/imported"}
|
test_data = {CONF_PORT: "/dev/imported"}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import locative
|
from homeassistant.components import locative
|
||||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||||
from homeassistant.components.locative import DOMAIN, TRACKER_UPDATE
|
from homeassistant.components.locative import DOMAIN, TRACKER_UPDATE
|
||||||
|
@ -39,7 +39,7 @@ async def webhook_id(hass, locative_client):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"locative", context={"source": "user"}
|
"locative", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,9 @@ async def test_already_configured_with_ignored(hass):
|
||||||
"""Test ignored entries do not break checking for existing entries."""
|
"""Test ignored entries do not break checking for existing entries."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
|
@ -160,7 +160,7 @@ async def test_reauthentication_flow(
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=old_entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=old_entry.data
|
||||||
)
|
)
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import hmac
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import mailgun, webhook
|
from homeassistant.components import mailgun, webhook
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_DOMAIN
|
from homeassistant.const import CONF_API_KEY, CONF_DOMAIN
|
||||||
|
@ -35,7 +35,7 @@ async def webhook_id_with_api_key(hass):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mailgun", context={"source": "user"}
|
"mailgun", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ async def webhook_id_without_api_key(hass):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mailgun", context={"source": "user"}
|
"mailgun", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,10 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -239,7 +242,10 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -275,7 +281,10 @@ async def test_reauth_account_locked(hass: HomeAssistant) -> None:
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -311,7 +320,10 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -347,7 +359,10 @@ async def test_reauth_unknown_error(hass: HomeAssistant) -> None:
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -383,7 +398,10 @@ async def test_reauth_user_has_new_email_address(hass: HomeAssistant) -> None:
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "entry_id": mock_config.entry_id},
|
context={
|
||||||
|
"source": config_entries.SOURCE_REAUTH,
|
||||||
|
"entry_id": mock_config.entry_id,
|
||||||
|
},
|
||||||
data=FIXTURE_USER_INPUT,
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.met.const import DOMAIN, HOME_LOCATION_NAME
|
from homeassistant.components.met.const import DOMAIN, HOME_LOCATION_NAME
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE
|
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE
|
||||||
|
@ -20,7 +21,7 @@ def met_setup_fixture():
|
||||||
async def test_show_config_form(hass):
|
async def test_show_config_form(hass):
|
||||||
"""Test show configuration form."""
|
"""Test show configuration form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -38,7 +39,7 @@ async def test_flow_with_home_location(hass):
|
||||||
hass.config.elevation = 3
|
hass.config.elevation = 3
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -61,7 +62,7 @@ async def test_create_entry(hass):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
@ -89,7 +90,7 @@ async def test_flow_entry_already_exists(hass):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -136,7 +137,7 @@ async def test_import_step(hass):
|
||||||
"track_home": True,
|
"track_home": True,
|
||||||
}
|
}
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Test Met weather entity."""
|
"""Test Met weather entity."""
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.met import DOMAIN
|
from homeassistant.components.met import DOMAIN
|
||||||
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -55,7 +56,7 @@ async def test_not_tracking_home(hass, mock_weather):
|
||||||
|
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
"met",
|
"met",
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={"name": "Somewhere", "latitude": 10, "longitude": 20, "elevation": 0},
|
data={"name": "Somewhere", "latitude": 10, "longitude": 20, "elevation": 0},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
import librouteros
|
import librouteros
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import mikrotik
|
from homeassistant.components import mikrotik
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -81,7 +81,9 @@ def mock_api_connection_error():
|
||||||
async def test_import(hass, api):
|
async def test_import(hass, api):
|
||||||
"""Test import step."""
|
"""Test import step."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "import"}, data=DEMO_CONFIG
|
mikrotik.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data=DEMO_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
@ -98,7 +100,7 @@ async def test_flow_works(hass, api):
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "user"}
|
mikrotik.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -150,7 +152,7 @@ async def test_host_already_configured(hass, auth_error):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "user"}
|
mikrotik.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
|
@ -168,7 +170,7 @@ async def test_name_exists(hass, api):
|
||||||
user_input[CONF_HOST] = "0.0.0.1"
|
user_input[CONF_HOST] = "0.0.0.1"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "user"}
|
mikrotik.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=user_input
|
result["flow_id"], user_input=user_input
|
||||||
|
@ -182,7 +184,7 @@ async def test_connection_error(hass, conn_error):
|
||||||
"""Test error when connection is unsuccessful."""
|
"""Test error when connection is unsuccessful."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "user"}
|
mikrotik.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
|
@ -195,7 +197,7 @@ async def test_wrong_credentials(hass, auth_error):
|
||||||
"""Test error when credentials are wrong."""
|
"""Test error when credentials are wrong."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
mikrotik.DOMAIN, context={"source": "user"}
|
mikrotik.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.mill.const import DOMAIN
|
from homeassistant.components.mill.const import DOMAIN
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ def mill_setup_fixture():
|
||||||
async def test_show_config_form(hass):
|
async def test_show_config_form(hass):
|
||||||
"""Test show configuration form."""
|
"""Test show configuration form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -35,7 +36,7 @@ async def test_create_entry(hass):
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=True):
|
with patch("mill.Mill.connect", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
@ -60,7 +61,7 @@ async def test_flow_entry_already_exists(hass):
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=True):
|
with patch("mill.Mill.connect", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -84,7 +85,7 @@ async def test_connection_error(hass):
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=False):
|
with patch("mill.Mill.connect", return_value=False):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ async def test_user_connection_works(hass, mock_try_connection, mock_finish_setu
|
||||||
mock_try_connection.return_value = True
|
mock_try_connection.return_value = True
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mqtt", context={"source": "user"}
|
"mqtt", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ async def test_user_connection_fails(hass, mock_try_connection, mock_finish_setu
|
||||||
mock_try_connection.return_value = False
|
mock_try_connection.return_value = False
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mqtt", context={"source": "user"}
|
"mqtt", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ async def test_manual_config_set(hass, mock_try_connection, mock_finish_setup):
|
||||||
mock_try_connection.return_value = True
|
mock_try_connection.return_value = True
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mqtt", context={"source": "user"}
|
"mqtt", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ async def test_user_single_instance(hass):
|
||||||
MockConfigEntry(domain="mqtt").add_to_hass(hass)
|
MockConfigEntry(domain="mqtt").add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mqtt", context={"source": "user"}
|
"mqtt", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
@ -105,7 +105,7 @@ async def test_hassio_single_instance(hass):
|
||||||
MockConfigEntry(domain="mqtt").add_to_hass(hass)
|
MockConfigEntry(domain="mqtt").add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"mqtt", context={"source": "hassio"}
|
"mqtt", context={"source": config_entries.SOURCE_HASSIO}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
@ -125,7 +125,7 @@ async def test_hassio_confirm(hass, mock_try_connection, mock_finish_setup):
|
||||||
"password": "mock-pass",
|
"password": "mock-pass",
|
||||||
"protocol": "3.1.1",
|
"protocol": "3.1.1",
|
||||||
},
|
},
|
||||||
context={"source": "hassio"},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
|
|
|
@ -88,7 +88,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -107,7 +107,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -36,7 +36,7 @@ async def test_abort_if_existing_entry(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"netatmo",
|
"netatmo",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.onewire.const import (
|
||||||
DEFAULT_SYSBUS_MOUNT_DIR,
|
DEFAULT_SYSBUS_MOUNT_DIR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL
|
from homeassistant.config_entries import CONN_CLASS_LOCAL_POLL, SOURCE_USER
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
|
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
|
||||||
|
|
||||||
from .const import MOCK_OWPROXY_DEVICES, MOCK_SYSBUS_DEVICES
|
from .const import MOCK_OWPROXY_DEVICES, MOCK_SYSBUS_DEVICES
|
||||||
|
@ -26,7 +26,7 @@ async def setup_onewire_sysbus_integration(hass):
|
||||||
"""Create the 1-Wire integration."""
|
"""Create the 1-Wire integration."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
data={
|
data={
|
||||||
CONF_TYPE: CONF_TYPE_SYSBUS,
|
CONF_TYPE: CONF_TYPE_SYSBUS,
|
||||||
CONF_MOUNT_DIR: DEFAULT_SYSBUS_MOUNT_DIR,
|
CONF_MOUNT_DIR: DEFAULT_SYSBUS_MOUNT_DIR,
|
||||||
|
@ -51,7 +51,7 @@ async def setup_onewire_owserver_integration(hass):
|
||||||
"""Create the 1-Wire integration."""
|
"""Create the 1-Wire integration."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
data={
|
data={
|
||||||
CONF_TYPE: CONF_TYPE_OWSERVER,
|
CONF_TYPE: CONF_TYPE_OWSERVER,
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
@ -76,7 +76,7 @@ async def setup_onewire_patched_owserver_integration(hass):
|
||||||
"""Create the 1-Wire integration."""
|
"""Create the 1-Wire integration."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
data={
|
data={
|
||||||
CONF_TYPE: CONF_TYPE_OWSERVER,
|
CONF_TYPE: CONF_TYPE_OWSERVER,
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.config_entries import (
|
||||||
ENTRY_STATE_LOADED,
|
ENTRY_STATE_LOADED,
|
||||||
ENTRY_STATE_NOT_LOADED,
|
ENTRY_STATE_NOT_LOADED,
|
||||||
ENTRY_STATE_SETUP_RETRY,
|
ENTRY_STATE_SETUP_RETRY,
|
||||||
|
SOURCE_USER,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
|
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
@ -29,7 +30,7 @@ async def test_owserver_connect_failure(hass):
|
||||||
"""Test connection failure raises ConfigEntryNotReady."""
|
"""Test connection failure raises ConfigEntryNotReady."""
|
||||||
config_entry_owserver = MockConfigEntry(
|
config_entry_owserver = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
data={
|
data={
|
||||||
CONF_TYPE: CONF_TYPE_OWSERVER,
|
CONF_TYPE: CONF_TYPE_OWSERVER,
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
@ -58,7 +59,7 @@ async def test_failed_owserver_listing(hass):
|
||||||
"""Create the 1-Wire integration."""
|
"""Create the 1-Wire integration."""
|
||||||
config_entry_owserver = MockConfigEntry(
|
config_entry_owserver = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
source="user",
|
source=SOURCE_USER,
|
||||||
data={
|
data={
|
||||||
CONF_TYPE: CONF_TYPE_OWSERVER,
|
CONF_TYPE: CONF_TYPE_OWSERVER,
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
|
|
@ -137,7 +137,7 @@ async def setup_onvif_integration(
|
||||||
options=None,
|
options=None,
|
||||||
unique_id=MAC,
|
unique_id=MAC,
|
||||||
entry_id="1",
|
entry_id="1",
|
||||||
source="user",
|
source=config_entries.SOURCE_USER,
|
||||||
):
|
):
|
||||||
"""Create an ONVIF config entry."""
|
"""Create an ONVIF config entry."""
|
||||||
if not config:
|
if not config:
|
||||||
|
@ -180,7 +180,7 @@ async def test_flow_discovered_devices(hass):
|
||||||
"""Test that config flow works for discovered devices."""
|
"""Test that config flow works for discovered devices."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -245,7 +245,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
|
||||||
await setup_onvif_integration(hass)
|
await setup_onvif_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -296,7 +296,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -348,7 +348,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||||
async def test_flow_manual_entry(hass):
|
async def test_flow_manual_entry(hass):
|
||||||
"""Test that config flow works for discovered devices."""
|
"""Test that config flow works for discovered devices."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
|
@ -105,7 +105,9 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -129,7 +131,9 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
side_effect=aiohttp.ClientError,
|
side_effect=aiohttp.ClientError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -158,7 +162,9 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=FIXTURE_USER_INPUT
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH},
|
||||||
|
data=FIXTURE_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.owntracks import config_flow
|
from homeassistant.components.owntracks import config_flow
|
||||||
from homeassistant.components.owntracks.config_flow import CONF_CLOUDHOOK, CONF_SECRET
|
from homeassistant.components.owntracks.config_flow import CONF_CLOUDHOOK, CONF_SECRET
|
||||||
from homeassistant.components.owntracks.const import DOMAIN
|
from homeassistant.components.owntracks.const import DOMAIN
|
||||||
|
@ -143,7 +143,7 @@ async def test_unload(hass):
|
||||||
"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup"
|
"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup"
|
||||||
) as mock_forward:
|
) as mock_forward:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}, data={}
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(mock_forward.mock_calls) == 1
|
assert len(mock_forward.mock_calls) == 1
|
||||||
|
@ -175,7 +175,7 @@ async def test_with_cloud_sub(hass):
|
||||||
return_value="https://hooks.nabu.casa/ABCD",
|
return_value="https://hooks.nabu.casa/ABCD",
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data={}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data={}
|
||||||
)
|
)
|
||||||
|
|
||||||
entry = result["result"]
|
entry = result["result"]
|
||||||
|
|
|
@ -26,6 +26,7 @@ from homeassistant.config_entries import (
|
||||||
ENTRY_STATE_LOADED,
|
ENTRY_STATE_LOADED,
|
||||||
SOURCE_INTEGRATION_DISCOVERY,
|
SOURCE_INTEGRATION_DISCOVERY,
|
||||||
SOURCE_REAUTH,
|
SOURCE_REAUTH,
|
||||||
|
SOURCE_USER,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -52,7 +53,7 @@ async def test_bad_credentials(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -85,7 +86,7 @@ async def test_bad_hostname(hass, mock_plex_calls):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -119,7 +120,7 @@ async def test_unknown_exception(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -150,7 +151,7 @@ async def test_no_servers_found(hass, mock_plex_calls, requests_mock, empty_payl
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -181,7 +182,7 @@ async def test_single_available_server(hass, mock_plex_calls):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -226,7 +227,7 @@ async def test_multiple_servers_with_selection(
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -290,7 +291,7 @@ async def test_adding_last_unconfigured_server(
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -350,7 +351,7 @@ async def test_all_available_servers_configured(
|
||||||
).add_to_hass(hass)
|
).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -478,7 +479,7 @@ async def test_external_timed_out(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -508,7 +509,7 @@ async def test_callback_view(hass, aiohttp_client):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -545,7 +546,7 @@ async def test_manual_config(hass, mock_plex_calls):
|
||||||
|
|
||||||
# Basic mode
|
# Basic mode
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -555,7 +556,8 @@ async def test_manual_config(hass, mock_plex_calls):
|
||||||
|
|
||||||
# Advanced automatic
|
# Advanced automatic
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user", "show_advanced_options": True}
|
config_flow.DOMAIN,
|
||||||
|
context={"source": SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -572,7 +574,8 @@ async def test_manual_config(hass, mock_plex_calls):
|
||||||
|
|
||||||
# Advanced manual
|
# Advanced manual
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user", "show_advanced_options": True}
|
config_flow.DOMAIN,
|
||||||
|
context={"source": SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -668,7 +671,8 @@ async def test_manual_config_with_token(hass, mock_plex_calls):
|
||||||
"""Test creating via manual configuration with only token."""
|
"""Test creating via manual configuration with only token."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user", "show_advanced_options": True}
|
config_flow.DOMAIN,
|
||||||
|
context={"source": SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
|
@ -159,7 +159,9 @@ async def test_already_configured_with_ignored(hass):
|
||||||
"""Test ignored entries do not break checking for existing entries."""
|
"""Test ignored entries do not break checking for existing entries."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -220,7 +222,7 @@ async def test_form_reauth(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
from pyps4_2ndscreen.errors import CredentialTimeout
|
from pyps4_2ndscreen.errors import CredentialTimeout
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import ps4
|
from homeassistant.components import ps4
|
||||||
from homeassistant.components.ps4.config_flow import LOCAL_UDP_PORT
|
from homeassistant.components.ps4.config_flow import LOCAL_UDP_PORT
|
||||||
from homeassistant.components.ps4.const import (
|
from homeassistant.components.ps4.const import (
|
||||||
|
@ -101,7 +101,7 @@ async def test_full_flow_implementation(hass):
|
||||||
# User Step Started, results in Step Creds
|
# User Step Started, results in Step Creds
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -142,7 +142,7 @@ async def test_multiple_flow_implementation(hass):
|
||||||
# User Step Started, results in Step Creds
|
# User Step Started, results in Step Creds
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -194,7 +194,7 @@ async def test_multiple_flow_implementation(hass):
|
||||||
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
|
return_value=[{"host-ip": MOCK_HOST}, {"host-ip": MOCK_HOST_ADDITIONAL}],
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -247,7 +247,7 @@ async def test_port_bind_abort(hass):
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_UDP_PORT):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_UDP_PORT):
|
||||||
reason = "port_987_bind_error"
|
reason = "port_987_bind_error"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == reason
|
assert result["reason"] == reason
|
||||||
|
@ -255,7 +255,7 @@ async def test_port_bind_abort(hass):
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_TCP_PORT):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_TCP_PORT):
|
||||||
reason = "port_997_bind_error"
|
reason = "port_997_bind_error"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == reason
|
assert result["reason"] == reason
|
||||||
|
@ -267,7 +267,7 @@ async def test_duplicate_abort(hass):
|
||||||
|
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -297,7 +297,7 @@ async def test_additional_device(hass):
|
||||||
|
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -370,7 +370,7 @@ async def test_no_devices_found_abort(hass):
|
||||||
"""Test that failure to find devices aborts flow."""
|
"""Test that failure to find devices aborts flow."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -395,7 +395,7 @@ async def test_manual_mode(hass):
|
||||||
"""Test host specified in manual mode is passed to Step Link."""
|
"""Test host specified in manual mode is passed to Step Link."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -423,7 +423,7 @@ async def test_credential_abort(hass):
|
||||||
"""Test that failure to get credentials aborts flow."""
|
"""Test that failure to get credentials aborts flow."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -441,7 +441,7 @@ async def test_credential_timeout(hass):
|
||||||
"""Test that Credential Timeout shows error."""
|
"""Test that Credential Timeout shows error."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -460,7 +460,7 @@ async def test_wrong_pin_error(hass):
|
||||||
"""Test that incorrect pin throws an error."""
|
"""Test that incorrect pin throws an error."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -492,7 +492,7 @@ async def test_device_connection_error(hass):
|
||||||
"""Test that device not connected or on throws an error."""
|
"""Test that device not connected or on throws an error."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
@ -524,7 +524,7 @@ async def test_manual_mode_no_ip_error(hass):
|
||||||
"""Test no IP specified in manual mode throws an error."""
|
"""Test no IP specified in manual mode throws an error."""
|
||||||
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "creds"
|
assert result["step_id"] == "creds"
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.pvpc_hourly_pricing import ATTR_TARIFF, DOMAIN
|
from homeassistant.components.pvpc_hourly_pricing import ATTR_TARIFF, DOMAIN
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -34,7 +34,7 @@ async def test_config_flow(
|
||||||
|
|
||||||
with patch("homeassistant.util.dt.utcnow", new=mock_now):
|
with patch("homeassistant.util.dt.utcnow", new=mock_now):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ async def test_config_flow(
|
||||||
|
|
||||||
# Check abort when configuring another with same tariff
|
# Check abort when configuring another with same tariff
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -66,7 +66,7 @@ async def test_config_flow(
|
||||||
|
|
||||||
# and add it again with UI
|
# and add it again with UI
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -128,7 +128,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -820,7 +820,9 @@ async def test_dhcp_discovery_with_ignored(hass):
|
||||||
"""Test ignored entries do not break checking for existing entries."""
|
"""Test ignored entries do not break checking for existing entries."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
|
|
@ -6,6 +6,7 @@ from samsungctl.exceptions import AccessDenied, UnhandledResponse
|
||||||
from samsungtvws.exceptions import ConnectionFailure
|
from samsungtvws.exceptions import ConnectionFailure
|
||||||
from websocket import WebSocketProtocolException
|
from websocket import WebSocketProtocolException
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.samsungtv.const import (
|
from homeassistant.components.samsungtv.const import (
|
||||||
CONF_MANUFACTURER,
|
CONF_MANUFACTURER,
|
||||||
CONF_MODEL,
|
CONF_MODEL,
|
||||||
|
@ -102,7 +103,7 @@ async def test_user_legacy(hass, remote):
|
||||||
"""Test starting a flow by user."""
|
"""Test starting a flow by user."""
|
||||||
# show form
|
# show form
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -129,7 +130,7 @@ async def test_user_websocket(hass, remotews):
|
||||||
):
|
):
|
||||||
# show form
|
# show form
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -157,7 +158,7 @@ async def test_user_legacy_missing_auth(hass):
|
||||||
), patch("homeassistant.components.samsungtv.config_flow.socket"):
|
), patch("homeassistant.components.samsungtv.config_flow.socket"):
|
||||||
# legacy device missing authentication
|
# legacy device missing authentication
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "auth_missing"
|
assert result["reason"] == "auth_missing"
|
||||||
|
@ -171,7 +172,7 @@ async def test_user_legacy_not_supported(hass):
|
||||||
), patch("homeassistant.components.samsungtv.config_flow.socket"):
|
), patch("homeassistant.components.samsungtv.config_flow.socket"):
|
||||||
# legacy device not supported
|
# legacy device not supported
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
@ -190,7 +191,7 @@ async def test_user_websocket_not_supported(hass):
|
||||||
):
|
):
|
||||||
# websocket device not supported
|
# websocket device not supported
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
@ -208,7 +209,7 @@ async def test_user_not_successful(hass):
|
||||||
"homeassistant.components.samsungtv.config_flow.socket"
|
"homeassistant.components.samsungtv.config_flow.socket"
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
@ -226,7 +227,7 @@ async def test_user_not_successful_2(hass):
|
||||||
"homeassistant.components.samsungtv.config_flow.socket"
|
"homeassistant.components.samsungtv.config_flow.socket"
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
@ -237,13 +238,13 @@ async def test_user_already_configured(hass, remote):
|
||||||
|
|
||||||
# entry was added
|
# entry was added
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
|
||||||
# failed as already configured
|
# failed as already configured
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -254,7 +255,7 @@ async def test_ssdp(hass, remote):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -277,7 +278,9 @@ async def test_ssdp_noprefix(hass, remote):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA_NOPREFIX
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_SSDP},
|
||||||
|
data=MOCK_SSDP_DATA_NOPREFIX,
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -304,7 +307,7 @@ async def test_ssdp_legacy_missing_auth(hass):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -326,7 +329,7 @@ async def test_ssdp_legacy_not_supported(hass):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -352,7 +355,7 @@ async def test_ssdp_websocket_not_supported(hass):
|
||||||
):
|
):
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -379,7 +382,7 @@ async def test_ssdp_not_successful(hass):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -406,7 +409,7 @@ async def test_ssdp_not_successful_2(hass):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
@ -424,14 +427,14 @@ async def test_ssdp_already_in_progress(hass, remote):
|
||||||
|
|
||||||
# confirm to add the entry
|
# confirm to add the entry
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
# failed as already in progress
|
# failed as already in progress
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
@ -442,7 +445,7 @@ async def test_ssdp_already_configured(hass, remote):
|
||||||
|
|
||||||
# entry was added
|
# entry was added
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
entry = result["result"]
|
entry = result["result"]
|
||||||
|
@ -452,7 +455,7 @@ async def test_ssdp_already_configured(hass, remote):
|
||||||
|
|
||||||
# failed as already configured
|
# failed as already configured
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||||
)
|
)
|
||||||
assert result2["type"] == "abort"
|
assert result2["type"] == "abort"
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
@ -477,7 +480,7 @@ async def test_autodetect_websocket(hass, remote, remotews):
|
||||||
remotews.return_value = remote
|
remotews.return_value = remote
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
assert result["data"][CONF_METHOD] == "websocket"
|
assert result["data"][CONF_METHOD] == "websocket"
|
||||||
|
@ -503,7 +506,7 @@ async def test_autodetect_websocket_ssl(hass, remote, remotews):
|
||||||
remotews.return_value = remote
|
remotews.return_value = remote
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
assert result["data"][CONF_METHOD] == "websocket"
|
assert result["data"][CONF_METHOD] == "websocket"
|
||||||
|
@ -522,7 +525,7 @@ async def test_autodetect_auth_missing(hass, remote):
|
||||||
side_effect=[AccessDenied("Boom")],
|
side_effect=[AccessDenied("Boom")],
|
||||||
) as remote:
|
) as remote:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "auth_missing"
|
assert result["reason"] == "auth_missing"
|
||||||
|
@ -537,7 +540,7 @@ async def test_autodetect_not_supported(hass, remote):
|
||||||
side_effect=[UnhandledResponse("Boom")],
|
side_effect=[UnhandledResponse("Boom")],
|
||||||
) as remote:
|
) as remote:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
@ -549,7 +552,7 @@ async def test_autodetect_legacy(hass, remote):
|
||||||
"""Test for send key with autodetection of protocol."""
|
"""Test for send key with autodetection of protocol."""
|
||||||
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote:
|
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
assert result["data"][CONF_METHOD] == "legacy"
|
assert result["data"][CONF_METHOD] == "legacy"
|
||||||
|
@ -567,7 +570,7 @@ async def test_autodetect_none(hass, remote, remotews):
|
||||||
side_effect=OSError("Boom"),
|
side_effect=OSError("Boom"),
|
||||||
) as remotews:
|
) as remotews:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
|
@ -137,7 +137,7 @@ async def test_dhcp(hass):
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "dhcp"},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
data={
|
data={
|
||||||
HOSTNAME: "Pentair: 01-01-01",
|
HOSTNAME: "Pentair: 01-01-01",
|
||||||
IP_ADDRESS: "1.1.1.1",
|
IP_ADDRESS: "1.1.1.1",
|
||||||
|
|
|
@ -73,7 +73,9 @@ async def test_reauth_success(hass: HomeAssistant):
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
||||||
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -99,7 +101,7 @@ async def test_reauth(
|
||||||
with patch("sharkiqpy.AylaApi.async_sign_in", side_effect=side_effect):
|
with patch("sharkiqpy.AylaApi.async_sign_in", side_effect=side_effect):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth", "unique_id": UNIQUE_ID},
|
context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
||||||
data=CONFIG,
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from simplipy.errors import (
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.simplisafe import DOMAIN
|
from homeassistant.components.simplisafe import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -107,7 +107,7 @@ async def test_step_reauth(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "reauth"},
|
context={"source": SOURCE_REAUTH},
|
||||||
data={CONF_CODE: "1234", CONF_USERNAME: "user@email.com"},
|
data={CONF_CODE: "1234", CONF_USERNAME: "user@email.com"},
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.sma.const import DOMAIN
|
from homeassistant.components.sma.const import DOMAIN
|
||||||
|
|
||||||
from . import MOCK_CUSTOM_SETUP_DATA, MOCK_DEVICE
|
from . import MOCK_CUSTOM_SETUP_DATA, MOCK_DEVICE
|
||||||
|
@ -18,7 +19,7 @@ def mock_config_entry():
|
||||||
title=MOCK_DEVICE["name"],
|
title=MOCK_DEVICE["name"],
|
||||||
unique_id=MOCK_DEVICE["serial"],
|
unique_id=MOCK_DEVICE["serial"],
|
||||||
data=MOCK_CUSTOM_SETUP_DATA,
|
data=MOCK_CUSTOM_SETUP_DATA,
|
||||||
source="import",
|
source=config_entries.SOURCE_IMPORT,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from aiohttp import ClientResponseError
|
||||||
from pysmartthings import APIResponseError
|
from pysmartthings import APIResponseError
|
||||||
from pysmartthings.installedapp import format_install_url
|
from pysmartthings.installedapp import format_install_url
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.smartthings import smartapp
|
from homeassistant.components.smartthings import smartapp
|
||||||
from homeassistant.components.smartthings.const import (
|
from homeassistant.components.smartthings.const import (
|
||||||
CONF_APP_ID,
|
CONF_APP_ID,
|
||||||
|
@ -31,7 +31,7 @@ async def test_import_shows_user_step(hass):
|
||||||
"""Test import source shows the user form."""
|
"""Test import source shows the user form."""
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "import"}
|
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -56,7 +56,7 @@ async def test_entry_created(hass, app, app_oauth_client, location, smartthings_
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -127,7 +127,7 @@ async def test_entry_created_from_update_event(
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -198,7 +198,7 @@ async def test_entry_created_existing_app_new_oauth_client(
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -282,7 +282,7 @@ async def test_entry_created_existing_app_copies_oauth_client(
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -372,7 +372,7 @@ async def test_entry_created_with_cloudhook(
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -434,7 +434,7 @@ async def test_invalid_webhook_aborts(hass):
|
||||||
{"external_url": "http://example.local:8123"},
|
{"external_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "invalid_webhook_url"
|
assert result["reason"] == "invalid_webhook_url"
|
||||||
|
@ -450,7 +450,7 @@ async def test_invalid_token_shows_error(hass):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -487,7 +487,7 @@ async def test_unauthorized_token_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -524,7 +524,7 @@ async def test_forbidden_token_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -564,7 +564,7 @@ async def test_webhook_problem_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -603,7 +603,7 @@ async def test_api_error_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -641,7 +641,7 @@ async def test_unknown_response_error_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -675,7 +675,7 @@ async def test_unknown_error_shows_error(hass, smartthings_mock):
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -717,7 +717,7 @@ async def test_no_available_locations_aborts(
|
||||||
|
|
||||||
# Webhook confirmation shown
|
# Webhook confirmation shown
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
|
@ -6,6 +6,7 @@ from aiohttp import ClientConnectionError, ClientResponseError
|
||||||
from pysmartthings import InstalledAppStatus, OAuthToken
|
from pysmartthings import InstalledAppStatus, OAuthToken
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import cloud, smartthings
|
from homeassistant.components import cloud, smartthings
|
||||||
from homeassistant.components.smartthings.const import (
|
from homeassistant.components.smartthings.const import (
|
||||||
CONF_CLOUDHOOK_URL,
|
CONF_CLOUDHOOK_URL,
|
||||||
|
@ -41,7 +42,7 @@ async def test_migration_creates_new_flow(hass, smartthings_mock, config_entry):
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
assert len(flows) == 1
|
assert len(flows) == 1
|
||||||
assert flows[0]["handler"] == "smartthings"
|
assert flows[0]["handler"] == "smartthings"
|
||||||
assert flows[0]["context"] == {"source": "import"}
|
assert flows[0]["context"] == {"source": config_entries.SOURCE_IMPORT}
|
||||||
|
|
||||||
|
|
||||||
async def test_unrecoverable_api_errors_create_new_flow(
|
async def test_unrecoverable_api_errors_create_new_flow(
|
||||||
|
@ -71,7 +72,7 @@ async def test_unrecoverable_api_errors_create_new_flow(
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
assert len(flows) == 1
|
assert len(flows) == 1
|
||||||
assert flows[0]["handler"] == "smartthings"
|
assert flows[0]["handler"] == "smartthings"
|
||||||
assert flows[0]["context"] == {"source": "import"}
|
assert flows[0]["context"] == {"source": config_entries.SOURCE_IMPORT}
|
||||||
hass.config_entries.flow.async_abort(flows[0]["flow_id"])
|
hass.config_entries.flow.async_abort(flows[0]["flow_id"])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -465,7 +465,9 @@ async def test_already_configured_with_ignored(hass):
|
||||||
"""Test ignored entries do not break checking for existing entries."""
|
"""Test ignored entries do not break checking for existing entries."""
|
||||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN, data={}, source="ignore")
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN, data={}, source=config_entries.SOURCE_IGNORE
|
||||||
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
from speedtest import NoMatchedServers
|
from speedtest import NoMatchedServers
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import speedtestdotnet
|
from homeassistant.components import speedtestdotnet
|
||||||
from homeassistant.components.speedtestdotnet.const import (
|
from homeassistant.components.speedtestdotnet.const import (
|
||||||
CONF_MANUAL,
|
CONF_MANUAL,
|
||||||
|
@ -34,7 +34,7 @@ def mock_setup():
|
||||||
async def test_flow_works(hass, mock_setup):
|
async def test_flow_works(hass, mock_setup):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
speedtestdotnet.DOMAIN, context={"source": "user"}
|
speedtestdotnet.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -53,7 +53,7 @@ async def test_import_fails(hass, mock_setup):
|
||||||
mock_api.return_value.get_servers.side_effect = NoMatchedServers
|
mock_api.return_value.get_servers.side_effect = NoMatchedServers
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
speedtestdotnet.DOMAIN,
|
speedtestdotnet.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
CONF_SERVER_ID: "223",
|
CONF_SERVER_ID: "223",
|
||||||
CONF_MANUAL: True,
|
CONF_MANUAL: True,
|
||||||
|
@ -71,7 +71,7 @@ async def test_import_success(hass, mock_setup):
|
||||||
with patch("speedtest.Speedtest"):
|
with patch("speedtest.Speedtest"):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
speedtestdotnet.DOMAIN,
|
speedtestdotnet.DOMAIN,
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={
|
data={
|
||||||
CONF_SERVER_ID: "1",
|
CONF_SERVER_ID: "1",
|
||||||
CONF_MANUAL: True,
|
CONF_MANUAL: True,
|
||||||
|
@ -132,7 +132,7 @@ async def test_integration_already_configured(hass):
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
speedtestdotnet.DOMAIN, context={"source": "user"}
|
speedtestdotnet.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -5,7 +5,7 @@ from spotipy import SpotifyException
|
||||||
|
|
||||||
from homeassistant import data_entry_flow, setup
|
from homeassistant import data_entry_flow, setup
|
||||||
from homeassistant.components.spotify.const import DOMAIN
|
from homeassistant.components.spotify.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ async def test_reauthentication(
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=old_entry.data
|
DOMAIN, context={"source": SOURCE_REAUTH}, data=old_entry.data
|
||||||
)
|
)
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
|
@ -246,7 +246,7 @@ async def test_reauth_account_mismatch(
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=old_entry.data
|
DOMAIN, context={"source": SOURCE_REAUTH}, data=old_entry.data
|
||||||
)
|
)
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
|
|
|
@ -23,7 +23,7 @@ async def init_integration(
|
||||||
config=None,
|
config=None,
|
||||||
options=None,
|
options=None,
|
||||||
entry_id="1",
|
entry_id="1",
|
||||||
source="user",
|
source=config_entries.SOURCE_USER,
|
||||||
side_effect=None,
|
side_effect=None,
|
||||||
usage=None,
|
usage=None,
|
||||||
):
|
):
|
||||||
|
|
|
@ -11,7 +11,7 @@ async def test_form(hass):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
# First get the form
|
# First get the form
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
SRP_ENERGY_DOMAIN, context={"source": "user"}
|
SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -40,7 +40,7 @@ async def test_form(hass):
|
||||||
async def test_form_invalid_auth(hass):
|
async def test_form_invalid_auth(hass):
|
||||||
"""Test user config with invalid auth."""
|
"""Test user config with invalid auth."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
SRP_ENERGY_DOMAIN, context={"source": "user"}
|
SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -58,7 +58,7 @@ async def test_form_invalid_auth(hass):
|
||||||
async def test_form_value_error(hass):
|
async def test_form_value_error(hass):
|
||||||
"""Test user config that throws a value error."""
|
"""Test user config that throws a value error."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
SRP_ENERGY_DOMAIN, context={"source": "user"}
|
SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -76,7 +76,7 @@ async def test_form_value_error(hass):
|
||||||
async def test_form_unknown_exception(hass):
|
async def test_form_unknown_exception(hass):
|
||||||
"""Test user config that throws an unknown exception."""
|
"""Test user config that throws an unknown exception."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
SRP_ENERGY_DOMAIN, context={"source": "user"}
|
SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -106,7 +106,7 @@ async def test_integration_already_configured(hass):
|
||||||
"""Test integration is already configured."""
|
"""Test integration is already configured."""
|
||||||
await init_integration(hass)
|
await init_integration(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
SRP_ENERGY_DOMAIN, context={"source": "user"}
|
SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -6,6 +6,7 @@ from unittest.mock import patch
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
@ -39,7 +40,9 @@ async def test_scan_match_st(hass, caplog):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "ssdp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_SSDP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
ssdp.ATTR_SSDP_ST: "mock-st",
|
ssdp.ATTR_SSDP_ST: "mock-st",
|
||||||
ssdp.ATTR_SSDP_LOCATION: None,
|
ssdp.ATTR_SSDP_LOCATION: None,
|
||||||
|
@ -88,7 +91,9 @@ async def test_scan_match_upnp_devicedesc(hass, aioclient_mock, key):
|
||||||
assert len(aioclient_mock.mock_calls) == 1
|
assert len(aioclient_mock.mock_calls) == 1
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "ssdp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_SSDP
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_scan_not_all_present(hass, aioclient_mock):
|
async def test_scan_not_all_present(hass, aioclient_mock):
|
||||||
|
@ -266,7 +271,9 @@ async def test_invalid_characters(hass, aioclient_mock):
|
||||||
|
|
||||||
assert len(mock_init.mock_calls) == 1
|
assert len(mock_init.mock_calls) == 1
|
||||||
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
assert mock_init.mock_calls[0][1][0] == "mock-domain"
|
||||||
assert mock_init.mock_calls[0][2]["context"] == {"source": "ssdp"}
|
assert mock_init.mock_calls[0][2]["context"] == {
|
||||||
|
"source": config_entries.SOURCE_SSDP
|
||||||
|
}
|
||||||
assert mock_init.mock_calls[0][2]["data"] == {
|
assert mock_init.mock_calls[0][2]["data"] == {
|
||||||
"ssdp_location": "http://1.1.1.1",
|
"ssdp_location": "http://1.1.1.1",
|
||||||
"ssdp_st": "mock-st",
|
"ssdp_st": "mock-st",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Tests for StarLine config flow."""
|
"""Tests for StarLine config flow."""
|
||||||
import requests_mock
|
import requests_mock
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.starline import config_flow
|
from homeassistant.components.starline import config_flow
|
||||||
|
|
||||||
TEST_APP_ID = "666"
|
TEST_APP_ID = "666"
|
||||||
|
@ -42,7 +43,7 @@ async def test_flow_works(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN, context={"source": "user"}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "auth_app"
|
assert result["step_id"] == "auth_app"
|
||||||
|
@ -76,7 +77,7 @@ async def test_step_auth_app_code_falls(hass):
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={
|
data={
|
||||||
config_flow.CONF_APP_ID: TEST_APP_ID,
|
config_flow.CONF_APP_ID: TEST_APP_ID,
|
||||||
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
||||||
|
@ -99,7 +100,7 @@ async def test_step_auth_app_token_falls(hass):
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={
|
data={
|
||||||
config_flow.CONF_APP_ID: TEST_APP_ID,
|
config_flow.CONF_APP_ID: TEST_APP_ID,
|
||||||
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
||||||
|
|
|
@ -125,7 +125,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -144,7 +144,7 @@ async def test_form_homekit(hass):
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.mqtt.models import Message
|
from homeassistant.components.mqtt.models import Message
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -9,7 +10,7 @@ async def test_mqtt_abort_if_existing_entry(hass, mqtt_mock):
|
||||||
MockConfigEntry(domain="tasmota").add_to_hass(hass)
|
MockConfigEntry(domain="tasmota").add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "mqtt"}
|
"tasmota", context={"source": config_entries.SOURCE_MQTT}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -20,7 +21,7 @@ async def test_mqtt_abort_invalid_topic(hass, mqtt_mock):
|
||||||
"""Check MQTT flow aborts if discovery topic is invalid."""
|
"""Check MQTT flow aborts if discovery topic is invalid."""
|
||||||
discovery_info = Message("", "", 0, False, subscribed_topic="custom_prefix/##")
|
discovery_info = Message("", "", 0, False, subscribed_topic="custom_prefix/##")
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "mqtt"}, data=discovery_info
|
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "invalid_discovery_info"
|
assert result["reason"] == "invalid_discovery_info"
|
||||||
|
@ -30,7 +31,7 @@ async def test_mqtt_setup(hass, mqtt_mock) -> None:
|
||||||
"""Test we can finish a config flow through MQTT with custom prefix."""
|
"""Test we can finish a config flow through MQTT with custom prefix."""
|
||||||
discovery_info = Message("", "", 0, False, subscribed_topic="custom_prefix/123/#")
|
discovery_info = Message("", "", 0, False, subscribed_topic="custom_prefix/123/#")
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "mqtt"}, data=discovery_info
|
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ async def test_mqtt_setup(hass, mqtt_mock) -> None:
|
||||||
async def test_user_setup(hass, mqtt_mock):
|
async def test_user_setup(hass, mqtt_mock):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "user"}
|
"tasmota", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -60,7 +61,8 @@ async def test_user_setup(hass, mqtt_mock):
|
||||||
async def test_user_setup_advanced(hass, mqtt_mock):
|
async def test_user_setup_advanced(hass, mqtt_mock):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "user", "show_advanced_options": True}
|
"tasmota",
|
||||||
|
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -77,7 +79,8 @@ async def test_user_setup_advanced(hass, mqtt_mock):
|
||||||
async def test_user_setup_advanced_strip_wildcard(hass, mqtt_mock):
|
async def test_user_setup_advanced_strip_wildcard(hass, mqtt_mock):
|
||||||
"""Test we can finish a config flow."""
|
"""Test we can finish a config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "user", "show_advanced_options": True}
|
"tasmota",
|
||||||
|
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -94,7 +97,8 @@ async def test_user_setup_advanced_strip_wildcard(hass, mqtt_mock):
|
||||||
async def test_user_setup_invalid_topic_prefix(hass, mqtt_mock):
|
async def test_user_setup_invalid_topic_prefix(hass, mqtt_mock):
|
||||||
"""Test abort on invalid discovery topic."""
|
"""Test abort on invalid discovery topic."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "user", "show_advanced_options": True}
|
"tasmota",
|
||||||
|
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
||||||
|
@ -111,7 +115,7 @@ async def test_user_single_instance(hass, mqtt_mock):
|
||||||
MockConfigEntry(domain="tasmota").add_to_hass(hass)
|
MockConfigEntry(domain="tasmota").add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tasmota", context={"source": "user"}
|
"tasmota", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, MagicMock, PropertyMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.tibber.const import DOMAIN
|
from homeassistant.components.tibber.const import DOMAIN
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ def tibber_setup_fixture():
|
||||||
async def test_show_config_form(hass):
|
async def test_show_config_form(hass):
|
||||||
"""Test show configuration form."""
|
"""Test show configuration form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
@ -42,7 +43,7 @@ async def test_create_entry(hass):
|
||||||
|
|
||||||
with patch("tibber.Tibber", return_value=tibber_mock):
|
with patch("tibber.Tibber", return_value=tibber_mock):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "create_entry"
|
assert result["type"] == "create_entry"
|
||||||
|
@ -65,7 +66,7 @@ async def test_flow_entry_already_exists(hass):
|
||||||
|
|
||||||
with patch("tibber.Tibber.update_info", return_value=None):
|
with patch("tibber.Tibber.update_info", return_value=None):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.totalconnect.const import CONF_LOCATION, DOMAIN
|
from homeassistant.components.totalconnect.const import CONF_LOCATION, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_PASSWORD
|
from homeassistant.const import CONF_PASSWORD
|
||||||
|
|
||||||
from .common import (
|
from .common import (
|
||||||
|
@ -133,7 +133,7 @@ async def test_reauth(hass):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "reauth"}, data=entry.data
|
DOMAIN, context={"source": SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import traccar, zone
|
from homeassistant.components import traccar, zone
|
||||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||||
from homeassistant.components.traccar import DOMAIN, TRACKER_UPDATE
|
from homeassistant.components.traccar import DOMAIN, TRACKER_UPDATE
|
||||||
|
@ -66,7 +66,7 @@ async def webhook_id_fixture(hass, client):
|
||||||
{"external_url": "http://example.com"},
|
{"external_url": "http://example.com"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "user"}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components.tradfri import config_flow
|
from homeassistant.components.tradfri import config_flow
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -23,7 +23,7 @@ async def test_user_connection_successful(hass, mock_auth, mock_entry_setup):
|
||||||
mock_auth.side_effect = lambda hass, host, code: {"host": host, "gateway_id": "bla"}
|
mock_auth.side_effect = lambda hass, host, code: {"host": host, "gateway_id": "bla"}
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri", context={"source": "user"}
|
"tradfri", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -45,7 +45,7 @@ async def test_user_connection_timeout(hass, mock_auth, mock_entry_setup):
|
||||||
mock_auth.side_effect = config_flow.AuthError("timeout")
|
mock_auth.side_effect = config_flow.AuthError("timeout")
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri", context={"source": "user"}
|
"tradfri", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -63,7 +63,7 @@ async def test_user_connection_bad_key(hass, mock_auth, mock_entry_setup):
|
||||||
mock_auth.side_effect = config_flow.AuthError("invalid_security_code")
|
mock_auth.side_effect = config_flow.AuthError("invalid_security_code")
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri", context={"source": "user"}
|
"tradfri", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -82,7 +82,7 @@ async def test_discovery_connection(hass, mock_auth, mock_entry_setup):
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ async def test_import_connection(hass, mock_auth, mock_entry_setup):
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "123.123.123.123", "import_groups": True},
|
data={"host": "123.123.123.123", "import_groups": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ async def test_import_connection_no_groups(hass, mock_auth, mock_entry_setup):
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "123.123.123.123", "import_groups": False},
|
data={"host": "123.123.123.123", "import_groups": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ async def test_import_connection_legacy(hass, mock_gateway_info, mock_entry_setu
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "123.123.123.123", "key": "mock-key", "import_groups": True},
|
data={"host": "123.123.123.123", "key": "mock-key", "import_groups": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ async def test_import_connection_legacy_no_groups(
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"host": "123.123.123.123", "key": "mock-key", "import_groups": False},
|
data={"host": "123.123.123.123", "key": "mock-key", "import_groups": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ async def test_discovery_duplicate_aborted(hass):
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "new-host", "properties": {"id": "homekit-id"}},
|
data={"host": "new-host", "properties": {"id": "homekit-id"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -245,7 +245,9 @@ async def test_import_duplicate_aborted(hass):
|
||||||
MockConfigEntry(domain="tradfri", data={"host": "some-host"}).add_to_hass(hass)
|
MockConfigEntry(domain="tradfri", data={"host": "some-host"}).add_to_hass(hass)
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri", context={"source": "import"}, data={"host": "some-host"}
|
"tradfri",
|
||||||
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
|
data={"host": "some-host"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert flow["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert flow["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
@ -256,7 +258,7 @@ async def test_duplicate_discovery(hass, mock_auth, mock_entry_setup):
|
||||||
"""Test a duplicate discovery in progress is ignored."""
|
"""Test a duplicate discovery in progress is ignored."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -264,7 +266,7 @@ async def test_duplicate_discovery(hass, mock_auth, mock_entry_setup):
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
data={"host": "123.123.123.123", "properties": {"id": "homekit-id"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -281,7 +283,7 @@ async def test_discovery_updates_unique_id(hass):
|
||||||
|
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"tradfri",
|
"tradfri",
|
||||||
context={"source": "homekit"},
|
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||||
data={"host": "some-host", "properties": {"id": "homekit-id"}},
|
data={"host": "some-host", "properties": {"id": "homekit-id"}},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Tests for Tradfri setup."""
|
"""Tests for Tradfri setup."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import tradfri
|
from homeassistant.components import tradfri
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
@ -34,7 +35,7 @@ async def test_config_yaml_host_imported(hass):
|
||||||
progress = hass.config_entries.flow.async_progress()
|
progress = hass.config_entries.flow.async_progress()
|
||||||
assert len(progress) == 1
|
assert len(progress) == 1
|
||||||
assert progress[0]["handler"] == "tradfri"
|
assert progress[0]["handler"] == "tradfri"
|
||||||
assert progress[0]["context"] == {"source": "import"}
|
assert progress[0]["context"] == {"source": config_entries.SOURCE_IMPORT}
|
||||||
|
|
||||||
|
|
||||||
async def test_config_json_host_not_imported(hass):
|
async def test_config_json_host_not_imported(hass):
|
||||||
|
@ -71,7 +72,7 @@ async def test_config_json_host_imported(
|
||||||
|
|
||||||
config_entry = mock_entry_setup.mock_calls[0][1][1]
|
config_entry = mock_entry_setup.mock_calls[0][1][1]
|
||||||
assert config_entry.domain == "tradfri"
|
assert config_entry.domain == "tradfri"
|
||||||
assert config_entry.source == "import"
|
assert config_entry.source == config_entries.SOURCE_IMPORT
|
||||||
assert config_entry.title == "mock-host"
|
assert config_entry.title == "mock-host"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
from transmissionrpc.error import TransmissionError
|
from transmissionrpc.error import TransmissionError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import transmission
|
from homeassistant.components import transmission
|
||||||
from homeassistant.components.transmission import config_flow
|
from homeassistant.components.transmission import config_flow
|
||||||
from homeassistant.components.transmission.const import (
|
from homeassistant.components.transmission.const import (
|
||||||
|
@ -96,7 +96,7 @@ def init_config_flow(hass):
|
||||||
async def test_flow_user_config(hass, api):
|
async def test_flow_user_config(hass, api):
|
||||||
"""Test user config."""
|
"""Test user config."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}
|
transmission.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -106,7 +106,7 @@ async def test_flow_required_fields(hass, api):
|
||||||
"""Test with required fields only."""
|
"""Test with required fields only."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN,
|
transmission.DOMAIN,
|
||||||
context={"source": "user"},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data={CONF_NAME: NAME, CONF_HOST: HOST, CONF_PORT: PORT},
|
data={CONF_NAME: NAME, CONF_HOST: HOST, CONF_PORT: PORT},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,7 +120,9 @@ async def test_flow_required_fields(hass, api):
|
||||||
async def test_flow_all_provided(hass, api):
|
async def test_flow_all_provided(hass, api):
|
||||||
"""Test with all provided."""
|
"""Test with all provided."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}, data=MOCK_ENTRY
|
transmission.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=MOCK_ENTRY,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
@ -208,7 +210,9 @@ async def test_host_already_configured(hass, api):
|
||||||
mock_entry_unique_name = MOCK_ENTRY.copy()
|
mock_entry_unique_name = MOCK_ENTRY.copy()
|
||||||
mock_entry_unique_name[CONF_NAME] = "Transmission 1"
|
mock_entry_unique_name[CONF_NAME] = "Transmission 1"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_name
|
transmission.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=mock_entry_unique_name,
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -217,7 +221,9 @@ async def test_host_already_configured(hass, api):
|
||||||
mock_entry_unique_port[CONF_PORT] = 9092
|
mock_entry_unique_port[CONF_PORT] = 9092
|
||||||
mock_entry_unique_port[CONF_NAME] = "Transmission 2"
|
mock_entry_unique_port[CONF_NAME] = "Transmission 2"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_port
|
transmission.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=mock_entry_unique_port,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
@ -225,7 +231,9 @@ async def test_host_already_configured(hass, api):
|
||||||
mock_entry_unique_host[CONF_HOST] = "192.168.1.101"
|
mock_entry_unique_host[CONF_HOST] = "192.168.1.101"
|
||||||
mock_entry_unique_host[CONF_NAME] = "Transmission 3"
|
mock_entry_unique_host[CONF_NAME] = "Transmission 3"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_host
|
transmission.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=mock_entry_unique_host,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
@ -242,7 +250,9 @@ async def test_name_already_configured(hass, api):
|
||||||
mock_entry = MOCK_ENTRY.copy()
|
mock_entry = MOCK_ENTRY.copy()
|
||||||
mock_entry[CONF_HOST] = "0.0.0.0"
|
mock_entry[CONF_HOST] = "0.0.0.0"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry
|
transmission.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data=mock_entry,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Test the init file of Twilio."""
|
"""Test the init file of Twilio."""
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.components import twilio
|
from homeassistant.components import twilio
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
@ -12,7 +12,7 @@ async def test_config_flow_registers_webhook(hass, aiohttp_client):
|
||||||
{"internal_url": "http://example.local:8123"},
|
{"internal_url": "http://example.local:8123"},
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"twilio", context={"source": "user"}
|
"twilio", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM, result
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ async def test_flow_works(hass, aioclient_mock, mock_discovery):
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
mock_discovery.return_value = "1"
|
mock_discovery.return_value = "1"
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -157,7 +157,7 @@ async def test_flow_works(hass, aioclient_mock, mock_discovery):
|
||||||
async def test_flow_works_negative_discovery(hass, aioclient_mock, mock_discovery):
|
async def test_flow_works_negative_discovery(hass, aioclient_mock, mock_discovery):
|
||||||
"""Test config flow with a negative outcome of async_discovery_unifi."""
|
"""Test config flow with a negative outcome of async_discovery_unifi."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -174,7 +174,7 @@ async def test_flow_works_negative_discovery(hass, aioclient_mock, mock_discover
|
||||||
async def test_flow_multiple_sites(hass, aioclient_mock):
|
async def test_flow_multiple_sites(hass, aioclient_mock):
|
||||||
"""Test config flow works when finding multiple sites."""
|
"""Test config flow works when finding multiple sites."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -222,7 +222,7 @@ async def test_flow_raise_already_configured(hass, aioclient_mock):
|
||||||
await setup_unifi_integration(hass, aioclient_mock)
|
await setup_unifi_integration(hass, aioclient_mock)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -277,7 +277,7 @@ async def test_flow_aborts_configuration_updated(hass, aioclient_mock):
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -321,7 +321,7 @@ async def test_flow_aborts_configuration_updated(hass, aioclient_mock):
|
||||||
async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
|
async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -348,7 +348,7 @@ async def test_flow_fails_user_credentials_faulty(hass, aioclient_mock):
|
||||||
async def test_flow_fails_controller_unavailable(hass, aioclient_mock):
|
async def test_flow_fails_controller_unavailable(hass, aioclient_mock):
|
||||||
"""Test config flow."""
|
"""Test config flow."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
UNIFI_DOMAIN, context={"source": "user"}
|
UNIFI_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
|
@ -170,7 +170,7 @@ async def test_discovery(hass):
|
||||||
"""Test discovery flow works."""
|
"""Test discovery flow works."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -200,7 +200,7 @@ async def test_discovery_cannot_connect(hass):
|
||||||
"""Test discovery aborts if cannot connect."""
|
"""Test discovery aborts if cannot connect."""
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -219,13 +219,13 @@ async def test_discovery_cannot_connect(hass):
|
||||||
async def test_discovery_duplicate_data(hass):
|
async def test_discovery_duplicate_data(hass):
|
||||||
"""Test discovery aborts if same mDNS packet arrives."""
|
"""Test discovery aborts if same mDNS packet arrives."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "discovery_confirm"
|
assert result["step_id"] == "discovery_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
@ -252,7 +252,9 @@ async def test_discovery_updates_unique_id(hass):
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": "zeroconf"}, data=TEST_DISCOVERY
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
|
data=TEST_DISCOVERY,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Tests for config flow."""
|
"""Tests for config flow."""
|
||||||
from aiohttp.test_utils import TestClient
|
from aiohttp.test_utils import TestClient
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.withings import const
|
from homeassistant.components.withings import const
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -58,7 +59,8 @@ async def test_config_reauth_profile(
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": "reauth", "profile": "person0"}
|
const.DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_REAUTH, "profile": "person0"},
|
||||||
)
|
)
|
||||||
assert result
|
assert result
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
|
|
|
@ -10,7 +10,7 @@ import zigpy.config
|
||||||
from homeassistant import setup
|
from homeassistant import setup
|
||||||
from homeassistant.components.zha import config_flow
|
from homeassistant.components.zha import config_flow
|
||||||
from homeassistant.components.zha.core.const import CONF_RADIO_TYPE, DOMAIN, RadioType
|
from homeassistant.components.zha.core.const import CONF_RADIO_TYPE, DOMAIN, RadioType
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||||
from homeassistant.const import CONF_SOURCE
|
from homeassistant.const import CONF_SOURCE
|
||||||
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
|
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ async def test_discovery(detect_mock, hass):
|
||||||
"properties": {"name": "tube_123456"},
|
"properties": {"name": "tube_123456"},
|
||||||
}
|
}
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"zha", context={"source": "zeroconf"}, data=service_info
|
"zha", context={"source": SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
flow["flow_id"], user_input={}
|
flow["flow_id"], user_input={}
|
||||||
|
@ -71,7 +71,7 @@ async def test_discovery_already_setup(detect_mock, hass):
|
||||||
MockConfigEntry(domain=DOMAIN, data={"usb_path": "/dev/ttyUSB1"}).add_to_hass(hass)
|
MockConfigEntry(domain=DOMAIN, data={"usb_path": "/dev/ttyUSB1"}).add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"zha", context={"source": "zeroconf"}, data=service_info
|
"zha", context={"source": SOURCE_ZEROCONF}, data=service_info
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Test Z-Wave Websocket API."""
|
"""Test Z-Wave Websocket API."""
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components.zwave.const import (
|
from homeassistant.components.zwave.const import (
|
||||||
CONF_AUTOHEAL,
|
CONF_AUTOHEAL,
|
||||||
|
@ -83,6 +84,6 @@ async def test_zwave_ozw_migration_api(hass, mock_openzwave, hass_ws_client):
|
||||||
assert result["flow_id"] == "mock_flow_id"
|
assert result["flow_id"] == "mock_flow_id"
|
||||||
assert async_init.call_args == call(
|
assert async_init.call_args == call(
|
||||||
"ozw",
|
"ozw",
|
||||||
context={"source": "import"},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={"usb_path": "/dev/zwave", "network_key": NETWORK_KEY},
|
data={"usb_path": "/dev/zwave", "network_key": NETWORK_KEY},
|
||||||
)
|
)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue