From 1c5b4dbd97bf36a03a39792d7503a1331ca6632e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 5 May 2020 21:34:51 -0700 Subject: [PATCH] Add current step that is in progress (#35272) --- homeassistant/data_entry_flow.py | 7 ++++++- tests/components/config/test_config_entries.py | 7 ++++++- tests/test_data_entry_flow.py | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/homeassistant/data_entry_flow.py b/homeassistant/data_entry_flow.py index 340ec671eda..49195e1a89a 100644 --- a/homeassistant/data_entry_flow.py +++ b/homeassistant/data_entry_flow.py @@ -94,7 +94,12 @@ class FlowManager(abc.ABC): def async_progress(self) -> List[Dict]: """Return the flows in progress.""" return [ - {"flow_id": flow.flow_id, "handler": flow.handler, "context": flow.context} + { + "flow_id": flow.flow_id, + "handler": flow.handler, + "context": flow.context, + "step_id": flow.cur_step["step_id"], + } for flow in self._progress.values() if flow.cur_step is not None ] diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index cee86fc046e..e5da27818fc 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -390,7 +390,12 @@ async def test_get_progress_index(hass, hass_ws_client): assert response["success"] assert response["result"] == [ - {"flow_id": form["flow_id"], "handler": "test", "context": {"source": "hassio"}} + { + "flow_id": form["flow_id"], + "handler": "test", + "step_id": "account", + "context": {"source": "hassio"}, + } ] diff --git a/tests/test_data_entry_flow.py b/tests/test_data_entry_flow.py index ad63dae6ee6..64b8587fe7c 100644 --- a/tests/test_data_entry_flow.py +++ b/tests/test_data_entry_flow.py @@ -58,7 +58,14 @@ async def test_configure_reuses_handler_instance(manager): assert form["errors"]["base"] == "1" form = await manager.async_configure(form["flow_id"]) assert form["errors"]["base"] == "2" - assert len(manager.async_progress()) == 1 + assert manager.async_progress() == [ + { + "flow_id": form["flow_id"], + "handler": "test", + "step_id": "init", + "context": {}, + } + ] assert len(manager.mock_created_entries) == 0