1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-03 20:56:06 +01:00
Files
core/tests/components/homeassistant_hardware/test_repairs.py
T
Stefan Agner ebd9934213 Add repair to migrate away from multiprotocol/Multi-PAN (#168431)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: puddly <32534428+puddly@users.noreply.github.com>
2026-05-27 16:37:02 +02:00

45 lines
1.6 KiB
Python

"""Tests for the homeassistant_hardware repairs helpers."""
from __future__ import annotations
import pytest
from homeassistant.components.homeassistant_hardware.repair_helpers import (
ISSUE_MULTI_PAN_MIGRATION,
async_create_multi_pan_migration_issue,
async_delete_multi_pan_migration_issue,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
from tests.common import MockConfigEntry
TEST_DOMAIN = "test_hardware"
@pytest.fixture
def ignore_translations_for_mock_domains() -> str:
"""Ignore translation check for the fake test_hardware domain."""
return TEST_DOMAIN
async def test_create_and_delete_multi_pan_migration_issue(
hass: HomeAssistant, issue_registry: ir.IssueRegistry
) -> None:
"""Test the helpers create and delete the migration issue per entry."""
entry = MockConfigEntry(domain=TEST_DOMAIN, title="Test HW", data={})
entry.add_to_hass(hass)
async_create_multi_pan_migration_issue(hass, TEST_DOMAIN, entry)
issue_id = f"{ISSUE_MULTI_PAN_MIGRATION}_{entry.entry_id}"
issue = issue_registry.async_get_issue(domain=TEST_DOMAIN, issue_id=issue_id)
assert issue is not None
assert issue.translation_key == ISSUE_MULTI_PAN_MIGRATION
assert issue.translation_placeholders == {"hardware_name": "Test HW"}
assert issue.data == {"entry_id": entry.entry_id}
assert issue.is_fixable
assert issue.severity is ir.IssueSeverity.WARNING
async_delete_multi_pan_migration_issue(hass, TEST_DOMAIN, entry)
assert issue_registry.async_get_issue(domain=TEST_DOMAIN, issue_id=issue_id) is None