Address late reviews for the enigma2 config flow (#115768)
* Address late reviews for the enigma2 config flow * fix tests * review comments * test for issues * Apply suggestions from code review Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
8275512130
commit
cdc49328be
3 changed files with 72 additions and 35 deletions
|
@ -10,8 +10,9 @@ import pytest
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components.enigma2.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
|
||||
from .conftest import (
|
||||
EXPECTED_OPTIONS,
|
||||
|
@ -96,6 +97,7 @@ async def test_form_import(
|
|||
test_config: dict[str, Any],
|
||||
expected_data: dict[str, Any],
|
||||
expected_options: dict[str, Any],
|
||||
issue_registry: IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we get the form with import source."""
|
||||
with (
|
||||
|
@ -115,6 +117,12 @@ async def test_form_import(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue = issue_registry.async_get_issue(
|
||||
HOMEASSISTANT_DOMAIN, f"deprecated_yaml_{DOMAIN}"
|
||||
)
|
||||
|
||||
assert issue
|
||||
assert issue.issue_domain == DOMAIN
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == test_config[CONF_HOST]
|
||||
assert result["data"] == expected_data
|
||||
|
@ -132,7 +140,10 @@ async def test_form_import(
|
|||
],
|
||||
)
|
||||
async def test_form_import_errors(
|
||||
hass: HomeAssistant, exception: Exception, error_type: str
|
||||
hass: HomeAssistant,
|
||||
exception: Exception,
|
||||
error_type: str,
|
||||
issue_registry: IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we handle errors on import."""
|
||||
with patch(
|
||||
|
@ -145,5 +156,11 @@ async def test_form_import_errors(
|
|||
data=TEST_IMPORT_FULL,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error_type}
|
||||
issue = issue_registry.async_get_issue(
|
||||
DOMAIN, f"deprecated_yaml_{DOMAIN}_import_issue_{error_type}"
|
||||
)
|
||||
|
||||
assert issue
|
||||
assert issue.issue_domain == DOMAIN
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == error_type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue