mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Improve tests of clean up when reauth flow aborts (#142592)
This commit is contained in:
parent
8625a36d1d
commit
70aacfce98
@ -1367,11 +1367,44 @@ async def test_async_forward_entry_setup_deprecated(
|
|||||||
) in caplog.text
|
) in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_reauth_issue(
|
async def test_reauth_issue_flow_returns_abort(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
manager: config_entries.ConfigEntries,
|
manager: config_entries.ConfigEntries,
|
||||||
issue_registry: ir.IssueRegistry,
|
issue_registry: ir.IssueRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""Test that we create/delete an issue when source is reauth.
|
||||||
|
|
||||||
|
In this test, the reauth flow returns abort.
|
||||||
|
"""
|
||||||
|
issue = await _test_reauth_issue(hass, manager, issue_registry)
|
||||||
|
|
||||||
|
result = await manager.flow.async_configure(issue.data["flow_id"], {})
|
||||||
|
assert result["type"] == FlowResultType.ABORT
|
||||||
|
assert len(issue_registry.issues) == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_reauth_issue_flow_aborted(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
manager: config_entries.ConfigEntries,
|
||||||
|
issue_registry: ir.IssueRegistry,
|
||||||
|
) -> None:
|
||||||
|
"""Test that we create/delete an issue when source is reauth.
|
||||||
|
|
||||||
|
In this test, the reauth flow is aborted.
|
||||||
|
"""
|
||||||
|
issue = await _test_reauth_issue(hass, manager, issue_registry)
|
||||||
|
|
||||||
|
manager.flow.async_abort(issue.data["flow_id"])
|
||||||
|
# This can be considered a bug, we should make sure the issue is always
|
||||||
|
# removed when the reauth flow is aborted.
|
||||||
|
assert len(issue_registry.issues) == 1
|
||||||
|
|
||||||
|
|
||||||
|
async def _test_reauth_issue(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
manager: config_entries.ConfigEntries,
|
||||||
|
issue_registry: ir.IssueRegistry,
|
||||||
|
) -> ir.IssueEntry:
|
||||||
"""Test that we create/delete an issue when source is reauth."""
|
"""Test that we create/delete an issue when source is reauth."""
|
||||||
assert len(issue_registry.issues) == 0
|
assert len(issue_registry.issues) == 0
|
||||||
|
|
||||||
@ -1407,10 +1440,7 @@ async def test_reauth_issue(
|
|||||||
translation_key="config_entry_reauth",
|
translation_key="config_entry_reauth",
|
||||||
translation_placeholders={"name": "test_title"},
|
translation_placeholders={"name": "test_title"},
|
||||||
)
|
)
|
||||||
|
return issue
|
||||||
result = await hass.config_entries.flow.async_configure(issue.data["flow_id"], {})
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
|
||||||
assert len(issue_registry.issues) == 0
|
|
||||||
|
|
||||||
|
|
||||||
async def test_loading_default_config(hass: HomeAssistant) -> None:
|
async def test_loading_default_config(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user