Use issue_registry fixture in core tests (#118042)
parent
dd22ee3dac
commit
0b4f1cff98
|
@ -77,12 +77,13 @@ async def test_login_flow_works(hass: HomeAssistant, manager) -> None:
|
|||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_create_repair_issue(hass: HomeAssistant):
|
||||
async def test_create_repair_issue(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
):
|
||||
"""Test legacy api password auth provider creates a reapir issue."""
|
||||
hass.auth = await auth.auth_manager_from_config(hass, [CONFIG], [])
|
||||
ensure_auth_manager_loaded(hass.auth)
|
||||
await async_setup_component(hass, "auth", {})
|
||||
issue_registry: ir.IssueRegistry = ir.async_get(hass)
|
||||
|
||||
assert issue_registry.async_get_issue(
|
||||
domain="auth", issue_id="deprecated_legacy_api_password"
|
||||
|
|
|
@ -1560,7 +1560,9 @@ def test_empty_schema_cant_find_module() -> None:
|
|||
|
||||
|
||||
def test_config_entry_only_schema(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test config_entry_only_config_schema."""
|
||||
expected_issue = "config_entry_only_test_domain"
|
||||
|
@ -1568,7 +1570,6 @@ def test_config_entry_only_schema(
|
|||
"The test_domain integration does not support YAML setup, please remove "
|
||||
"it from your configuration"
|
||||
)
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
cv.config_entry_only_config_schema("test_domain")({})
|
||||
assert expected_message not in caplog.text
|
||||
|
@ -1590,7 +1591,9 @@ def test_config_entry_only_schema_cant_find_module() -> None:
|
|||
|
||||
|
||||
def test_config_entry_only_schema_no_hass(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test if the hass context is not set in our context."""
|
||||
with patch(
|
||||
|
@ -1605,12 +1608,13 @@ def test_config_entry_only_schema_no_hass(
|
|||
"it from your configuration"
|
||||
)
|
||||
assert expected_message in caplog.text
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert not issue_registry.issues
|
||||
|
||||
|
||||
def test_platform_only_schema(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test config_entry_only_config_schema."""
|
||||
expected_issue = "platform_only_test_domain"
|
||||
|
@ -1618,8 +1622,6 @@ def test_platform_only_schema(
|
|||
"The test_domain integration does not support YAML setup, please remove "
|
||||
"it from your configuration"
|
||||
)
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
cv.platform_only_config_schema("test_domain")({})
|
||||
assert expected_message not in caplog.text
|
||||
assert not issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
|
|
|
@ -1983,18 +1983,19 @@ def test_identify_config_schema(domain, schema, expected) -> None:
|
|||
)
|
||||
|
||||
|
||||
async def test_core_config_schema_historic_currency(hass: HomeAssistant) -> None:
|
||||
async def test_core_config_schema_historic_currency(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test core config schema."""
|
||||
await config_util.async_process_ha_core_config(hass, {"currency": "LTT"})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue("homeassistant", "historic_currency")
|
||||
assert issue
|
||||
assert issue.translation_placeholders == {"currency": "LTT"}
|
||||
|
||||
|
||||
async def test_core_store_historic_currency(
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any]
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any], issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test core config store."""
|
||||
core_data = {
|
||||
|
@ -2008,7 +2009,6 @@ async def test_core_store_historic_currency(
|
|||
hass_storage["core.config"] = dict(core_data)
|
||||
await config_util.async_process_ha_core_config(hass, {})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue_id = "historic_currency"
|
||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||
assert issue
|
||||
|
@ -2019,11 +2019,12 @@ async def test_core_store_historic_currency(
|
|||
assert not issue
|
||||
|
||||
|
||||
async def test_core_config_schema_no_country(hass: HomeAssistant) -> None:
|
||||
async def test_core_config_schema_no_country(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test core config schema."""
|
||||
await config_util.async_process_ha_core_config(hass, {})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue("homeassistant", "country_not_configured")
|
||||
assert issue
|
||||
|
||||
|
@ -2037,12 +2038,14 @@ async def test_core_config_schema_no_country(hass: HomeAssistant) -> None:
|
|||
],
|
||||
)
|
||||
async def test_core_config_schema_legacy_template(
|
||||
hass: HomeAssistant, config: dict[str, Any], expected_issue: str | None
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, Any],
|
||||
expected_issue: str | None,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test legacy_template core config schema."""
|
||||
await config_util.async_process_ha_core_config(hass, config)
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
for issue_id in ("legacy_templates_true", "legacy_templates_false"):
|
||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||
assert issue if issue_id == expected_issue else not issue
|
||||
|
@ -2053,7 +2056,7 @@ async def test_core_config_schema_legacy_template(
|
|||
|
||||
|
||||
async def test_core_store_no_country(
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any]
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any], issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test core config store."""
|
||||
core_data = {
|
||||
|
@ -2065,7 +2068,6 @@ async def test_core_store_no_country(
|
|||
hass_storage["core.config"] = dict(core_data)
|
||||
await config_util.async_process_ha_core_config(hass, {})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue_id = "country_not_configured"
|
||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||
assert issue
|
||||
|
|
|
@ -504,7 +504,9 @@ async def test_remove_entry(
|
|||
|
||||
|
||||
async def test_remove_entry_cancels_reauth(
|
||||
hass: HomeAssistant, manager: config_entries.ConfigEntries
|
||||
hass: HomeAssistant,
|
||||
manager: config_entries.ConfigEntries,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Tests that removing a config entry, also aborts existing reauth flows."""
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
|
@ -523,7 +525,6 @@ async def test_remove_entry_cancels_reauth(
|
|||
assert flows[0]["context"]["source"] == config_entries.SOURCE_REAUTH
|
||||
assert entry.state is config_entries.ConfigEntryState.SETUP_ERROR
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue_id = f"config_entry_reauth_test_{entry.entry_id}"
|
||||
assert issue_registry.async_get_issue(HA_DOMAIN, issue_id)
|
||||
|
||||
|
@ -1120,10 +1121,11 @@ async def test_reauth_notification(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
async def test_reauth_issue(
|
||||
hass: HomeAssistant, manager: config_entries.ConfigEntries
|
||||
hass: HomeAssistant,
|
||||
manager: config_entries.ConfigEntries,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test that we create/delete an issue when source is reauth."""
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert len(issue_registry.issues) == 0
|
||||
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
|
|
Loading…
Reference in New Issue