Add current step that is in progress (#35272)

This commit is contained in:
Paulus Schoutsen 2020-05-05 21:34:51 -07:00 committed by GitHub
parent 56beec1ce9
commit 1c5b4dbd97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -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
]

View File

@ -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"},
}
]

View File

@ -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