mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Automatically generate config flow list (#23802)
* Add config flow to manifest.json * Still load config flows via config flow platform * Fix typo * Lint * Update config_flows.py" * Catch import error when setting up entry * Lint * Fix tests * Fix imports * Lint * Fix Unifi tests * Fix translation test * Add homekit_controller config flow
This commit is contained in:
@@ -12,9 +12,11 @@ from homeassistant.config_entries import HANDLERS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components.config import config_entries
|
||||
from homeassistant.generated import config_flows
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry, MockModule, mock_coro_func, mock_integration)
|
||||
MockConfigEntry, MockModule, mock_coro_func, mock_integration,
|
||||
mock_entity_platform)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -121,7 +123,7 @@ async def test_remove_entry_unauth(hass, client, hass_admin_user):
|
||||
@asyncio.coroutine
|
||||
def test_available_flows(hass, client):
|
||||
"""Test querying the available flows."""
|
||||
with patch.object(core_ce, 'FLOWS', ['hello', 'world']):
|
||||
with patch.object(config_flows, 'FLOWS', ['hello', 'world']):
|
||||
resp = yield from client.get(
|
||||
'/api/config/config_entries/flow_handlers')
|
||||
assert resp.status == 200
|
||||
@@ -137,6 +139,8 @@ def test_available_flows(hass, client):
|
||||
@asyncio.coroutine
|
||||
def test_initialize_flow(hass, client):
|
||||
"""Test we can initialize a flow."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
@asyncio.coroutine
|
||||
def async_step_user(self, user_input=None):
|
||||
@@ -221,6 +225,8 @@ async def test_initialize_flow_unauth(hass, client, hass_admin_user):
|
||||
@asyncio.coroutine
|
||||
def test_abort(hass, client):
|
||||
"""Test a flow that aborts."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
@asyncio.coroutine
|
||||
def async_step_user(self, user_input=None):
|
||||
@@ -244,6 +250,8 @@ def test_abort(hass, client):
|
||||
@asyncio.coroutine
|
||||
def test_create_account(hass, client):
|
||||
"""Test a flow that creates an account."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule('test', async_setup_entry=mock_coro_func(True)))
|
||||
@@ -286,6 +294,7 @@ def test_two_step_flow(hass, client):
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule('test', async_setup_entry=mock_coro_func(True)))
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
VERSION = 1
|
||||
@@ -352,6 +361,7 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user):
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule('test', async_setup_entry=mock_coro_func(True)))
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
VERSION = 1
|
||||
@@ -402,6 +412,8 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user):
|
||||
@asyncio.coroutine
|
||||
def test_get_progress_index(hass, client):
|
||||
"""Test querying for the flows that are in progress."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
VERSION = 5
|
||||
|
||||
@@ -441,6 +453,8 @@ async def test_get_progress_index_unauth(hass, client, hass_admin_user):
|
||||
@asyncio.coroutine
|
||||
def test_get_progress_flow(hass, client):
|
||||
"""Test we can query the API for same result as we get from init a flow."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
@asyncio.coroutine
|
||||
def async_step_user(self, user_input=None):
|
||||
@@ -474,6 +488,8 @@ def test_get_progress_flow(hass, client):
|
||||
|
||||
async def test_get_progress_flow_unauth(hass, client, hass_admin_user):
|
||||
"""Test we can can't query the API for result of flow."""
|
||||
mock_entity_platform(hass, 'config_flow.test', None)
|
||||
|
||||
class TestFlow(core_ce.ConfigFlow):
|
||||
async def async_step_user(self, user_input=None):
|
||||
schema = OrderedDict()
|
||||
|
||||
Reference in New Issue
Block a user