mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use issue_registry fixture in component tests (#118041)
This commit is contained in:
parent
cb62f4242e
commit
44f715bd02
@ -101,7 +101,10 @@ async def test_migration_1_2(hass: HomeAssistant, mock_pyairvisual) -> None:
|
||||
|
||||
|
||||
async def test_migration_2_3(
|
||||
hass: HomeAssistant, mock_pyairvisual, device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
mock_pyairvisual,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test migrating from version 2 to 3."""
|
||||
entry = MockConfigEntry(
|
||||
@ -134,5 +137,4 @@ async def test_migration_2_3(
|
||||
for domain, entry_count in ((DOMAIN, 0), (AIRVISUAL_PRO_DOMAIN, 1)):
|
||||
assert len(hass.config_entries.async_entries(domain)) == entry_count
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert len(issue_registry.issues) == 1
|
||||
|
@ -20,9 +20,9 @@ from homeassistant.const import (
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import Context, HomeAssistant, callback
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.entity_registry import async_get as async_get_entities
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.issue_registry import async_get
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import get_fixture_path
|
||||
@ -104,7 +104,9 @@ async def test_unknown_state_does_not_influence_probability(
|
||||
assert state.attributes.get("probability") == prior
|
||||
|
||||
|
||||
async def test_sensor_numeric_state(hass: HomeAssistant) -> None:
|
||||
async def test_sensor_numeric_state(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test sensor on numeric state platform observations."""
|
||||
config = {
|
||||
"binary_sensor": {
|
||||
@ -200,7 +202,7 @@ async def test_sensor_numeric_state(hass: HomeAssistant) -> None:
|
||||
|
||||
assert state.state == "off"
|
||||
|
||||
assert len(async_get(hass).issues) == 0
|
||||
assert len(issue_registry.issues) == 0
|
||||
|
||||
|
||||
async def test_sensor_state(hass: HomeAssistant) -> None:
|
||||
@ -329,7 +331,7 @@ async def test_sensor_value_template(hass: HomeAssistant) -> None:
|
||||
assert state.state == "off"
|
||||
|
||||
|
||||
async def test_threshold(hass: HomeAssistant) -> None:
|
||||
async def test_threshold(hass: HomeAssistant, issue_registry: ir.IssueRegistry) -> None:
|
||||
"""Test sensor on probability threshold limits."""
|
||||
config = {
|
||||
"binary_sensor": {
|
||||
@ -359,7 +361,7 @@ async def test_threshold(hass: HomeAssistant) -> None:
|
||||
assert round(abs(1.0 - state.attributes.get("probability")), 7) == 0
|
||||
|
||||
assert state.state == "on"
|
||||
assert len(async_get(hass).issues) == 0
|
||||
assert len(issue_registry.issues) == 0
|
||||
|
||||
|
||||
async def test_multiple_observations(hass: HomeAssistant) -> None:
|
||||
@ -513,7 +515,9 @@ async def test_multiple_numeric_observations(hass: HomeAssistant) -> None:
|
||||
assert state.attributes.get("observations")[1]["platform"] == "numeric_state"
|
||||
|
||||
|
||||
async def test_mirrored_observations(hass: HomeAssistant) -> None:
|
||||
async def test_mirrored_observations(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test whether mirrored entries are detected and appropriate issues are created."""
|
||||
|
||||
config = {
|
||||
@ -586,22 +590,24 @@ async def test_mirrored_observations(hass: HomeAssistant) -> None:
|
||||
"prior": 0.1,
|
||||
}
|
||||
}
|
||||
assert len(async_get(hass).issues) == 0
|
||||
assert len(issue_registry.issues) == 0
|
||||
assert await async_setup_component(hass, "binary_sensor", config)
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_set("sensor.test_monitored2", "on")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(async_get(hass).issues) == 3
|
||||
assert len(issue_registry.issues) == 3
|
||||
assert (
|
||||
async_get(hass).issues[
|
||||
issue_registry.issues[
|
||||
("bayesian", "mirrored_entry/Test_Binary/sensor.test_monitored1")
|
||||
]
|
||||
is not None
|
||||
)
|
||||
|
||||
|
||||
async def test_missing_prob_given_false(hass: HomeAssistant) -> None:
|
||||
async def test_missing_prob_given_false(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test whether missing prob_given_false are detected and appropriate issues are created."""
|
||||
|
||||
config = {
|
||||
@ -630,15 +636,15 @@ async def test_missing_prob_given_false(hass: HomeAssistant) -> None:
|
||||
"prior": 0.1,
|
||||
}
|
||||
}
|
||||
assert len(async_get(hass).issues) == 0
|
||||
assert len(issue_registry.issues) == 0
|
||||
assert await async_setup_component(hass, "binary_sensor", config)
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_set("sensor.test_monitored2", "on")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(async_get(hass).issues) == 3
|
||||
assert len(issue_registry.issues) == 3
|
||||
assert (
|
||||
async_get(hass).issues[
|
||||
issue_registry.issues[
|
||||
("bayesian", "no_prob_given_false/missingpgf/sensor.test_monitored1")
|
||||
]
|
||||
is not None
|
||||
|
@ -40,7 +40,7 @@ from homeassistant.components.bluetooth.match import (
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
@ -3151,6 +3151,7 @@ async def test_issue_outdated_haos_removed(
|
||||
mock_bleak_scanner_start: MagicMock,
|
||||
no_adapters: None,
|
||||
operating_system_85: None,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we do not create an issue on outdated haos anymore."""
|
||||
assert await async_setup_component(hass, bluetooth.DOMAIN, {})
|
||||
@ -3158,8 +3159,7 @@ async def test_issue_outdated_haos_removed(
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "haos_outdated")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "haos_outdated")
|
||||
assert issue is None
|
||||
|
||||
|
||||
@ -3168,6 +3168,7 @@ async def test_haos_9_or_later(
|
||||
mock_bleak_scanner_start: MagicMock,
|
||||
one_adapter: None,
|
||||
operating_system_90: None,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we do not create issues for haos 9.x or later."""
|
||||
entry = MockConfigEntry(
|
||||
@ -3178,8 +3179,7 @@ async def test_haos_9_or_later(
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "haos_outdated")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "haos_outdated")
|
||||
assert issue is None
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ import respx
|
||||
from homeassistant.components.bmw_connected_drive import DOMAIN as BMW_DOMAIN
|
||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.update_coordinator import UpdateFailed
|
||||
|
||||
from . import FIXTURE_CONFIG_ENTRY
|
||||
@ -100,7 +100,7 @@ async def test_init_reauth(
|
||||
hass: HomeAssistant,
|
||||
bmw_fixture: respx.Router,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the reauth form."""
|
||||
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.components.calendar import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .conftest import TEST_DOMAIN, MockCalendarEntity, MockConfigEntry
|
||||
@ -572,7 +572,7 @@ async def test_list_events_missing_fields(hass: HomeAssistant) -> None:
|
||||
|
||||
async def test_issue_deprecated_service_calendar_list_events(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the issue is raised on deprecated service weather.get_forecast."""
|
||||
|
@ -823,6 +823,7 @@ async def test_issue_aux_property_deprecated(
|
||||
translation_placeholders_extra: dict[str, str],
|
||||
report: str,
|
||||
module: str,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the issue is raised on deprecated auxiliary heater attributes."""
|
||||
|
||||
@ -894,8 +895,7 @@ async def test_issue_aux_property_deprecated(
|
||||
|
||||
assert climate_entity.state == HVACMode.HEAT
|
||||
|
||||
issues = ir.async_get(hass)
|
||||
issue = issues.async_get_issue("climate", "deprecated_climate_aux_test")
|
||||
issue = issue_registry.async_get_issue("climate", "deprecated_climate_aux_test")
|
||||
assert issue
|
||||
assert issue.issue_domain == "test"
|
||||
assert issue.issue_id == "deprecated_climate_aux_test"
|
||||
@ -954,6 +954,7 @@ async def test_no_issue_aux_property_deprecated_for_core(
|
||||
translation_placeholders_extra: dict[str, str],
|
||||
report: str,
|
||||
module: str,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the no issue on deprecated auxiliary heater attributes for core integrations."""
|
||||
|
||||
@ -1023,8 +1024,7 @@ async def test_no_issue_aux_property_deprecated_for_core(
|
||||
|
||||
assert climate_entity.state == HVACMode.HEAT
|
||||
|
||||
issues = ir.async_get(hass)
|
||||
issue = issues.async_get_issue("climate", "deprecated_climate_aux_test")
|
||||
issue = issue_registry.async_get_issue("climate", "deprecated_climate_aux_test")
|
||||
assert not issue
|
||||
|
||||
assert (
|
||||
@ -1038,6 +1038,7 @@ async def test_no_issue_no_aux_property(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
config_flow_fixture: None,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the issue is raised on deprecated auxiliary heater attributes."""
|
||||
|
||||
@ -1082,8 +1083,7 @@ async def test_no_issue_no_aux_property(
|
||||
|
||||
assert climate_entity.state == HVACMode.HEAT
|
||||
|
||||
issues = ir.async_get(hass)
|
||||
assert len(issues.issues) == 0
|
||||
assert len(issue_registry.issues) == 0
|
||||
|
||||
assert (
|
||||
"test::MockClimateEntityWithAux implements the `is_aux_heat` property or uses "
|
||||
|
@ -26,8 +26,7 @@ from homeassistant.components.homeassistant.exposed_entities import (
|
||||
)
|
||||
from homeassistant.const import CONTENT_TYPE_JSON, __version__ as HA_VERSION
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
@ -399,7 +398,7 @@ async def test_cloud_connection_info(hass: HomeAssistant) -> None:
|
||||
async def test_async_create_repair_issue_known(
|
||||
cloud: MagicMock,
|
||||
mock_cloud_setup: None,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
translation_key: str,
|
||||
) -> None:
|
||||
"""Test create repair issue for known repairs."""
|
||||
@ -417,7 +416,7 @@ async def test_async_create_repair_issue_known(
|
||||
async def test_async_create_repair_issue_unknown(
|
||||
cloud: MagicMock,
|
||||
mock_cloud_setup: None,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test not creating repair issue for unknown repairs."""
|
||||
identifier = "abc123"
|
||||
|
@ -27,8 +27,8 @@ from homeassistant.components.tts.helper import get_engine_instance
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry, IssueSeverity
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import PIPELINE_DATA
|
||||
@ -143,7 +143,7 @@ async def test_prefs_default_voice(
|
||||
|
||||
async def test_deprecated_platform_config(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
cloud: MagicMock,
|
||||
) -> None:
|
||||
"""Test cloud provider uses the preferences."""
|
||||
@ -157,7 +157,7 @@ async def test_deprecated_platform_config(
|
||||
assert issue.breaks_in_ha_version == "2024.9.0"
|
||||
assert issue.is_fixable is False
|
||||
assert issue.is_persistent is False
|
||||
assert issue.severity == IssueSeverity.WARNING
|
||||
assert issue.severity == ir.IssueSeverity.WARNING
|
||||
assert issue.translation_key == "deprecated_tts_platform_config"
|
||||
|
||||
|
||||
@ -463,7 +463,7 @@ async def test_migrating_pipelines(
|
||||
)
|
||||
async def test_deprecated_voice(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
cloud: MagicMock,
|
||||
hass_client: ClientSessionGenerator,
|
||||
data: dict[str, Any],
|
||||
@ -555,7 +555,7 @@ async def test_deprecated_voice(
|
||||
assert issue.breaks_in_ha_version == "2024.8.0"
|
||||
assert issue.is_fixable is True
|
||||
assert issue.is_persistent is True
|
||||
assert issue.severity == IssueSeverity.WARNING
|
||||
assert issue.severity == ir.IssueSeverity.WARNING
|
||||
assert issue.translation_key == "deprecated_voice"
|
||||
assert issue.translation_placeholders == {
|
||||
"deprecated_voice": deprecated_voice,
|
||||
@ -613,7 +613,7 @@ async def test_deprecated_voice(
|
||||
)
|
||||
async def test_deprecated_gender(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
cloud: MagicMock,
|
||||
hass_client: ClientSessionGenerator,
|
||||
data: dict[str, Any],
|
||||
@ -700,7 +700,7 @@ async def test_deprecated_gender(
|
||||
assert issue.breaks_in_ha_version == "2024.10.0"
|
||||
assert issue.is_fixable is True
|
||||
assert issue.is_persistent is True
|
||||
assert issue.severity == IssueSeverity.WARNING
|
||||
assert issue.severity == ir.IssueSeverity.WARNING
|
||||
assert issue.translation_key == "deprecated_gender"
|
||||
assert issue.translation_placeholders == {
|
||||
"integration_name": "Home Assistant Cloud",
|
||||
|
@ -10,10 +10,7 @@ from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_PORT
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.issue_registry import (
|
||||
IssueSeverity,
|
||||
async_get as async_get_issue_registry,
|
||||
)
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
@ -34,10 +31,10 @@ async def test_flow(
|
||||
exp_type,
|
||||
exp_result,
|
||||
exp_reason,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Run a flow with or without errors and return result."""
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(dynalite.DOMAIN, "deprecated_yaml")
|
||||
issue = issue_registry.async_get_issue(dynalite.DOMAIN, "deprecated_yaml")
|
||||
assert issue is None
|
||||
host = "1.2.3.4"
|
||||
with patch(
|
||||
@ -55,12 +52,12 @@ async def test_flow(
|
||||
assert result["result"].state == exp_result
|
||||
if exp_reason:
|
||||
assert result["reason"] == exp_reason
|
||||
issue = registry.async_get_issue(
|
||||
issue = issue_registry.async_get_issue(
|
||||
HOMEASSISTANT_DOMAIN, f"deprecated_yaml_{dynalite.DOMAIN}"
|
||||
)
|
||||
assert issue is not None
|
||||
assert issue.issue_domain == dynalite.DOMAIN
|
||||
assert issue.severity == IssueSeverity.WARNING
|
||||
assert issue.severity == ir.IssueSeverity.WARNING
|
||||
|
||||
|
||||
async def test_deprecated(
|
||||
|
@ -12,7 +12,7 @@ from homeassistant.components.enigma2.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
|
||||
from .conftest import (
|
||||
EXPECTED_OPTIONS,
|
||||
@ -97,7 +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,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we get the form with import source."""
|
||||
with (
|
||||
@ -143,7 +143,7 @@ async def test_form_import_errors(
|
||||
hass: HomeAssistant,
|
||||
exception: Exception,
|
||||
error_type: str,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we handle errors on import."""
|
||||
with patch(
|
||||
|
@ -52,6 +52,7 @@ async def test_esphome_device_service_calls_not_allowed(
|
||||
Awaitable[MockESPHomeDevice],
|
||||
],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test a device with service calls not allowed."""
|
||||
entity_info = []
|
||||
@ -74,7 +75,6 @@ async def test_esphome_device_service_calls_not_allowed(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_esphome_test) == 0
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(
|
||||
"esphome", "service_calls_not_enabled-11:22:33:44:55:aa"
|
||||
)
|
||||
@ -95,6 +95,7 @@ async def test_esphome_device_service_calls_allowed(
|
||||
Awaitable[MockESPHomeDevice],
|
||||
],
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test a device with service calls are allowed."""
|
||||
await async_setup_component(hass, "tag", {})
|
||||
@ -126,7 +127,6 @@ async def test_esphome_device_service_calls_allowed(
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(
|
||||
"esphome", "service_calls_not_enabled-11:22:33:44:55:aa"
|
||||
)
|
||||
@ -254,6 +254,7 @@ async def test_esphome_device_with_old_bluetooth(
|
||||
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
|
||||
Awaitable[MockESPHomeDevice],
|
||||
],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test a device with old bluetooth creates an issue."""
|
||||
entity_info = []
|
||||
@ -267,7 +268,6 @@ async def test_esphome_device_with_old_bluetooth(
|
||||
device_info={"bluetooth_proxy_feature_flags": 1, "esphome_version": "2023.3.0"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(
|
||||
"esphome", "ble_firmware_outdated-11:22:33:44:55:AA"
|
||||
)
|
||||
@ -284,6 +284,7 @@ async def test_esphome_device_with_password(
|
||||
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
|
||||
Awaitable[MockESPHomeDevice],
|
||||
],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test a device with legacy password creates an issue."""
|
||||
entity_info = []
|
||||
@ -308,7 +309,6 @@ async def test_esphome_device_with_password(
|
||||
entry=entry,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (
|
||||
issue_registry.async_get_issue(
|
||||
# This issue uses the ESPHome mac address which
|
||||
@ -327,6 +327,7 @@ async def test_esphome_device_with_current_bluetooth(
|
||||
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
|
||||
Awaitable[MockESPHomeDevice],
|
||||
],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test a device with recent bluetooth does not create an issue."""
|
||||
entity_info = []
|
||||
@ -343,7 +344,6 @@ async def test_esphome_device_with_current_bluetooth(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (
|
||||
# This issue uses the ESPHome device info mac address which
|
||||
# is always UPPER case
|
||||
|
@ -143,6 +143,7 @@ async def test_commands(
|
||||
service: str,
|
||||
command: str,
|
||||
extra: dict[str, Any],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test sending commands to the vacuum."""
|
||||
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
||||
@ -163,5 +164,4 @@ async def test_commands(
|
||||
)
|
||||
getattr(mock_account.robots[0], command).assert_called_once()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert set(issue_registry.issues.keys()) == issues
|
||||
|
@ -98,19 +98,21 @@ async def test_create_dashboards_when_not_onboarded(
|
||||
assert hass_storage[DOMAIN]["data"] == {"migrated": True}
|
||||
|
||||
|
||||
async def test_create_issue_when_not_manually_configured(hass: HomeAssistant) -> None:
|
||||
async def test_create_issue_when_not_manually_configured(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test creating issue registry issues."""
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert not issue_registry.async_get_issue(
|
||||
HOMEASSISTANT_DOMAIN, "deprecated_yaml_map"
|
||||
)
|
||||
|
||||
|
||||
async def test_create_issue_when_manually_configured(hass: HomeAssistant) -> None:
|
||||
async def test_create_issue_when_manually_configured(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test creating issue registry issues."""
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, "deprecated_yaml_map")
|
||||
|
@ -414,8 +414,7 @@ async def test_update_addon(
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_issue_registry_invalid_version(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
hass: HomeAssistant, matter_client: MagicMock, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test issue registry for invalid version."""
|
||||
original_connect_side_effect = matter_client.connect.side_effect
|
||||
@ -433,10 +432,9 @@ async def test_issue_registry_invalid_version(
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_reg = ir.async_get(hass)
|
||||
entry_state = entry.state
|
||||
assert entry_state is ConfigEntryState.SETUP_RETRY
|
||||
assert issue_reg.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
assert issue_registry.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
|
||||
matter_client.connect.side_effect = original_connect_side_effect
|
||||
|
||||
@ -444,7 +442,7 @@ async def test_issue_registry_invalid_version(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
assert not issue_reg.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
assert not issue_registry.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -40,7 +40,9 @@ DATASET_NO_CHANNEL = bytes.fromhex(
|
||||
)
|
||||
|
||||
|
||||
async def test_import_dataset(hass: HomeAssistant, mock_async_zeroconf: None) -> None:
|
||||
async def test_import_dataset(
|
||||
hass: HomeAssistant, mock_async_zeroconf: None, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test the active dataset is imported at setup."""
|
||||
add_service_listener_called = asyncio.Event()
|
||||
|
||||
@ -53,7 +55,6 @@ async def test_import_dataset(hass: HomeAssistant, mock_async_zeroconf: None) ->
|
||||
mock_async_zeroconf.async_remove_service_listener = AsyncMock()
|
||||
mock_async_zeroconf.async_get_service_info = AsyncMock()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert await thread.async_get_preferred_dataset(hass) is None
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
@ -123,15 +124,15 @@ async def test_import_dataset(hass: HomeAssistant, mock_async_zeroconf: None) ->
|
||||
|
||||
|
||||
async def test_import_share_radio_channel_collision(
|
||||
hass: HomeAssistant, multiprotocol_addon_manager_mock
|
||||
hass: HomeAssistant,
|
||||
multiprotocol_addon_manager_mock,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the active dataset is imported at setup.
|
||||
|
||||
This imports a dataset with different channel than ZHA when ZHA and OTBR share
|
||||
the radio.
|
||||
"""
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
multiprotocol_addon_manager_mock.async_get_channel.return_value = 15
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
@ -173,14 +174,15 @@ async def test_import_share_radio_channel_collision(
|
||||
|
||||
@pytest.mark.parametrize("dataset", [DATASET_CH15, DATASET_NO_CHANNEL])
|
||||
async def test_import_share_radio_no_channel_collision(
|
||||
hass: HomeAssistant, multiprotocol_addon_manager_mock, dataset: bytes
|
||||
hass: HomeAssistant,
|
||||
multiprotocol_addon_manager_mock,
|
||||
dataset: bytes,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the active dataset is imported at setup.
|
||||
|
||||
This imports a dataset when ZHA and OTBR share the radio.
|
||||
"""
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
multiprotocol_addon_manager_mock.async_get_channel.return_value = 15
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
@ -221,13 +223,13 @@ async def test_import_share_radio_no_channel_collision(
|
||||
@pytest.mark.parametrize(
|
||||
"dataset", [DATASET_INSECURE_NW_KEY, DATASET_INSECURE_PASSPHRASE]
|
||||
)
|
||||
async def test_import_insecure_dataset(hass: HomeAssistant, dataset: bytes) -> None:
|
||||
async def test_import_insecure_dataset(
|
||||
hass: HomeAssistant, dataset: bytes, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test the active dataset is imported at setup.
|
||||
|
||||
This imports a dataset with insecure settings.
|
||||
"""
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
data=CONFIG_ENTRY_DATA_MULTIPAN,
|
||||
domain=otbr.DOMAIN,
|
||||
|
@ -145,9 +145,10 @@ async def test_import_config_once(
|
||||
assert response["result"] == []
|
||||
|
||||
|
||||
async def test_create_issue_when_manually_configured(hass: HomeAssistant) -> None:
|
||||
async def test_create_issue_when_manually_configured(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test creating issue registry issues."""
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert issue_registry.async_get_issue(DOMAIN, "deprecated_yaml")
|
||||
|
@ -74,8 +74,11 @@ from homeassistant.const import (
|
||||
STATE_UNLOCKED,
|
||||
)
|
||||
from homeassistant.core import Context, CoreState, Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er, recorder as recorder_helper
|
||||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.helpers import (
|
||||
entity_registry as er,
|
||||
issue_registry as ir,
|
||||
recorder as recorder_helper,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.json import json_loads
|
||||
@ -1865,6 +1868,7 @@ async def test_database_lock_and_overflow(
|
||||
recorder_db_url: str,
|
||||
tmp_path: Path,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test writing events during lock leading to overflow the queue causes the database to unlock."""
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
@ -1915,8 +1919,7 @@ async def test_database_lock_and_overflow(
|
||||
assert "Database queue backlog reached more than" in caplog.text
|
||||
assert not instance.unlock_database()
|
||||
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "backup_failed_out_of_resources")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "backup_failed_out_of_resources")
|
||||
assert issue is not None
|
||||
assert "start_time" in issue.translation_placeholders
|
||||
start_time = issue.translation_placeholders["start_time"]
|
||||
@ -1931,6 +1934,7 @@ async def test_database_lock_and_overflow_checks_available_memory(
|
||||
recorder_db_url: str,
|
||||
tmp_path: Path,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test writing events during lock leading to overflow the queue causes the database to unlock."""
|
||||
if recorder_db_url.startswith(("mysql://", "postgresql://")):
|
||||
@ -2005,8 +2009,7 @@ async def test_database_lock_and_overflow_checks_available_memory(
|
||||
db_events = await instance.async_add_executor_job(_get_db_events)
|
||||
assert len(db_events) >= 2
|
||||
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "backup_failed_out_of_resources")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "backup_failed_out_of_resources")
|
||||
assert issue is not None
|
||||
assert "start_time" in issue.translation_placeholders
|
||||
start_time = issue.translation_placeholders["start_time"]
|
||||
|
@ -34,7 +34,7 @@ from homeassistant.components.recorder.util import (
|
||||
)
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .common import (
|
||||
@ -618,7 +618,11 @@ def test_warn_unsupported_dialect(
|
||||
],
|
||||
)
|
||||
async def test_issue_for_mariadb_with_MDEV_25020(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mysql_version, min_version
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mysql_version,
|
||||
min_version,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we create an issue for MariaDB versions affected.
|
||||
|
||||
@ -653,8 +657,7 @@ async def test_issue_for_mariadb_with_MDEV_25020(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "maria_db_range_index_regression")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "maria_db_range_index_regression")
|
||||
assert issue is not None
|
||||
assert issue.translation_placeholders == {"min_version": min_version}
|
||||
|
||||
@ -673,7 +676,10 @@ async def test_issue_for_mariadb_with_MDEV_25020(
|
||||
],
|
||||
)
|
||||
async def test_no_issue_for_mariadb_with_MDEV_25020(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mysql_version
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mysql_version,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we do not create an issue for MariaDB versions not affected.
|
||||
|
||||
@ -708,8 +714,7 @@ async def test_no_issue_for_mariadb_with_MDEV_25020(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
registry = async_get_issue_registry(hass)
|
||||
issue = registry.async_get_issue(DOMAIN, "maria_db_range_index_regression")
|
||||
issue = issue_registry.async_get_issue(DOMAIN, "maria_db_range_index_regression")
|
||||
assert issue is None
|
||||
|
||||
assert database_engine is not None
|
||||
|
@ -215,7 +215,7 @@ async def test_cleanup_deprecated_entities(
|
||||
|
||||
|
||||
async def test_no_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test no repairs issue is raised when http local url is used."""
|
||||
await async_process_ha_core_config(
|
||||
@ -225,7 +225,6 @@ async def test_no_repair_issue(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "https_webhook") not in issue_registry.issues
|
||||
assert (const.DOMAIN, "webhook_url") not in issue_registry.issues
|
||||
assert (const.DOMAIN, "enable_port") not in issue_registry.issues
|
||||
@ -234,7 +233,7 @@ async def test_no_repair_issue(
|
||||
|
||||
|
||||
async def test_https_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when https local url is used."""
|
||||
await async_process_ha_core_config(
|
||||
@ -253,12 +252,11 @@ async def test_https_repair_issue(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "https_webhook") in issue_registry.issues
|
||||
|
||||
|
||||
async def test_ssl_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when global ssl certificate is used."""
|
||||
assert await async_setup_component(hass, "webhook", {})
|
||||
@ -280,7 +278,6 @@ async def test_ssl_repair_issue(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "ssl") in issue_registry.issues
|
||||
|
||||
|
||||
@ -290,6 +287,7 @@ async def test_port_repair_issue(
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
protocol: str,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when auto enable of ports fails."""
|
||||
reolink_connect.set_net_port = AsyncMock(side_effect=ReolinkError("Test error"))
|
||||
@ -300,12 +298,11 @@ async def test_port_repair_issue(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "enable_port") in issue_registry.issues
|
||||
|
||||
|
||||
async def test_webhook_repair_issue(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test repairs issue is raised when the webhook url is unreachable."""
|
||||
with (
|
||||
@ -320,7 +317,6 @@ async def test_webhook_repair_issue(
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "webhook_url") in issue_registry.issues
|
||||
|
||||
|
||||
@ -328,11 +324,11 @@ async def test_firmware_repair_issue(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_connect: MagicMock,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test firmware issue is raised when too old firmware is used."""
|
||||
reolink_connect.sw_version_update_required = True
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert (const.DOMAIN, "firmware_update") in issue_registry.issues
|
||||
|
@ -14,14 +14,7 @@ from homeassistant.components.repairs.issue_handler import (
|
||||
)
|
||||
from homeassistant.const import __version__ as ha_version
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.issue_registry import (
|
||||
IssueSeverity,
|
||||
async_create_issue,
|
||||
async_delete_issue,
|
||||
async_ignore_issue,
|
||||
create_issue,
|
||||
delete_issue,
|
||||
)
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import mock_platform
|
||||
@ -67,7 +60,7 @@ async def test_create_update_issue(
|
||||
]
|
||||
|
||||
for issue in issues:
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
@ -98,7 +91,7 @@ async def test_create_update_issue(
|
||||
}
|
||||
|
||||
# Update an issue
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issues[0]["domain"],
|
||||
issues[0]["issue_id"],
|
||||
@ -147,7 +140,7 @@ async def test_create_issue_invalid_version(
|
||||
}
|
||||
|
||||
with pytest.raises(AwesomeVersionStrategyException):
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
@ -196,7 +189,7 @@ async def test_ignore_issue(
|
||||
]
|
||||
|
||||
for issue in issues:
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
@ -228,7 +221,7 @@ async def test_ignore_issue(
|
||||
|
||||
# Ignore a non-existing issue
|
||||
with pytest.raises(KeyError):
|
||||
async_ignore_issue(hass, issues[0]["domain"], "no_such_issue", True)
|
||||
ir.async_ignore_issue(hass, issues[0]["domain"], "no_such_issue", True)
|
||||
|
||||
await client.send_json({"id": 3, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -248,7 +241,7 @@ async def test_ignore_issue(
|
||||
}
|
||||
|
||||
# Ignore an existing issue
|
||||
async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True)
|
||||
ir.async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True)
|
||||
|
||||
await client.send_json({"id": 4, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -268,7 +261,7 @@ async def test_ignore_issue(
|
||||
}
|
||||
|
||||
# Ignore the same issue again
|
||||
async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True)
|
||||
ir.async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True)
|
||||
|
||||
await client.send_json({"id": 5, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -288,7 +281,7 @@ async def test_ignore_issue(
|
||||
}
|
||||
|
||||
# Update an ignored issue
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issues[0]["domain"],
|
||||
issues[0]["issue_id"],
|
||||
@ -315,7 +308,7 @@ async def test_ignore_issue(
|
||||
)
|
||||
|
||||
# Unignore the same issue
|
||||
async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], False)
|
||||
ir.async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], False)
|
||||
|
||||
await client.send_json({"id": 7, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -362,7 +355,7 @@ async def test_delete_issue(
|
||||
]
|
||||
|
||||
for issue in issues:
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
@ -393,7 +386,7 @@ async def test_delete_issue(
|
||||
}
|
||||
|
||||
# Delete a non-existing issue
|
||||
async_delete_issue(hass, issues[0]["domain"], "no_such_issue")
|
||||
ir.async_delete_issue(hass, issues[0]["domain"], "no_such_issue")
|
||||
|
||||
await client.send_json({"id": 2, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -413,7 +406,7 @@ async def test_delete_issue(
|
||||
}
|
||||
|
||||
# Delete an existing issue
|
||||
async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"])
|
||||
ir.async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"])
|
||||
|
||||
await client.send_json({"id": 3, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -422,7 +415,7 @@ async def test_delete_issue(
|
||||
assert msg["result"] == {"issues": []}
|
||||
|
||||
# Delete the same issue again
|
||||
async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"])
|
||||
ir.async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"])
|
||||
|
||||
await client.send_json({"id": 4, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
@ -434,7 +427,7 @@ async def test_delete_issue(
|
||||
freezer.move_to("2022-07-19 08:53:05")
|
||||
|
||||
for issue in issues:
|
||||
async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
@ -508,7 +501,7 @@ async def test_sync_methods(
|
||||
assert msg["result"] == {"issues": []}
|
||||
|
||||
def _create_issue() -> None:
|
||||
create_issue(
|
||||
ir.create_issue(
|
||||
hass,
|
||||
"fake_integration",
|
||||
"sync_issue",
|
||||
@ -516,7 +509,7 @@ async def test_sync_methods(
|
||||
is_fixable=True,
|
||||
is_persistent=False,
|
||||
learn_more_url="https://theuselessweb.com",
|
||||
severity=IssueSeverity.ERROR,
|
||||
severity=ir.IssueSeverity.ERROR,
|
||||
translation_key="abc_123",
|
||||
translation_placeholders={"abc": "123"},
|
||||
)
|
||||
@ -546,7 +539,7 @@ async def test_sync_methods(
|
||||
}
|
||||
|
||||
await hass.async_add_executor_job(
|
||||
delete_issue, hass, "fake_integration", "sync_issue"
|
||||
ir.delete_issue, hass, "fake_integration", "sync_issue"
|
||||
)
|
||||
await client.send_json({"id": 3, "type": "repairs/list_issues"})
|
||||
msg = await client.receive_json()
|
||||
|
@ -14,8 +14,7 @@ from homeassistant.components.ring import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
@ -247,7 +246,7 @@ async def test_error_on_device_update(
|
||||
|
||||
async def test_issue_deprecated_service_ring_update(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
requests_mock: requests_mock.Mocker,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
|
@ -8,7 +8,7 @@ from freezegun.api import FrozenDateTimeFactory
|
||||
from py17track.errors import SeventeenTrackError
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import goto_future, init_integration
|
||||
@ -311,7 +311,7 @@ async def test_non_valid_platform_config(
|
||||
async def test_full_valid_platform_config(
|
||||
hass: HomeAssistant,
|
||||
mock_seventeentrack: AsyncMock,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Ensure everything starts correctly."""
|
||||
assert await async_setup_component(hass, "sensor", VALID_PLATFORM_CONFIG_FULL)
|
||||
|
@ -33,9 +33,9 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from homeassistant.helpers.issue_registry import IssueRegistry
|
||||
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
|
||||
|
||||
from . import MOCK_MAC, init_integration, register_device, register_entity
|
||||
@ -560,7 +560,7 @@ async def test_device_not_calibrated(
|
||||
hass: HomeAssistant,
|
||||
mock_block_device: Mock,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
issue_registry: IssueRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test to create an issue when the device is not calibrated."""
|
||||
await init_integration(hass, 1, sleep_period=1000, model=MODEL_VALVE)
|
||||
|
@ -479,6 +479,7 @@ async def test_create_issue_valve_switch(
|
||||
mock_block_device: Mock,
|
||||
entity_registry_enabled_by_default: None,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we create an issue when an automation or script is using a deprecated entity."""
|
||||
monkeypatch.setitem(mock_block_device.status, "cloud", {"connected": False})
|
||||
@ -521,7 +522,6 @@ async def test_create_issue_valve_switch(
|
||||
|
||||
assert automations_with_entity(hass, entity_id)[0] == "automation.test"
|
||||
assert scripts_with_entity(hass, entity_id)[0] == "script.test"
|
||||
issue_registry: ir.IssueRegistry = ir.async_get(hass)
|
||||
|
||||
assert issue_registry.async_get_issue(DOMAIN, "deprecated_valve_switch")
|
||||
assert issue_registry.async_get_issue(
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.components.sonos.const import (
|
||||
SUB_FAIL_ISSUE_ID,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .conftest import SonosMockEvent, SonosMockSubscribe
|
||||
@ -19,11 +19,13 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_subscription_repair_issues(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, soco: SoCo, zgs_discovery
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
soco: SoCo,
|
||||
zgs_discovery,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test repair issues handling for failed subscriptions."""
|
||||
issue_registry = async_get_issue_registry(hass)
|
||||
|
||||
subscription: SonosMockSubscribe = soco.zoneGroupTopology.subscribe.return_value
|
||||
subscription.event_listener = Mock(address=("192.168.4.2", 1400))
|
||||
|
||||
|
@ -424,7 +424,10 @@ async def test_binary_data_from_yaml_setup(
|
||||
|
||||
|
||||
async def test_issue_when_using_old_query(
|
||||
recorder_mock: Recorder, hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
recorder_mock: Recorder,
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we create an issue for an old query that will do a full table scan."""
|
||||
|
||||
@ -433,7 +436,6 @@ async def test_issue_when_using_old_query(
|
||||
assert "Query contains entity_id but does not reference states_meta" in caplog.text
|
||||
|
||||
assert not hass.states.async_all()
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
config = YAML_CONFIG_FULL_TABLE_SCAN["sql"]
|
||||
|
||||
@ -457,6 +459,7 @@ async def test_issue_when_using_old_query_without_unique_id(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
yaml_config: dict[str, Any],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test we create an issue for an old query that will do a full table scan."""
|
||||
|
||||
@ -465,7 +468,6 @@ async def test_issue_when_using_old_query_without_unique_id(
|
||||
assert "Query contains entity_id but does not reference states_meta" in caplog.text
|
||||
|
||||
assert not hass.states.async_all()
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
config = yaml_config["sql"]
|
||||
query = config[CONF_QUERY]
|
||||
|
@ -578,6 +578,7 @@ async def test_same_topic(
|
||||
device_reg,
|
||||
entity_reg,
|
||||
setup_tasmota,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test detecting devices with same topic."""
|
||||
configs = [
|
||||
@ -624,7 +625,6 @@ async def test_same_topic(
|
||||
|
||||
# Verify a repairs issue was created
|
||||
issue_id = "topic_duplicated_tasmota_49A3BC/cmnd/"
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue("tasmota", issue_id)
|
||||
assert issue.data["mac"] == " ".join(config["mac"] for config in configs[0:2])
|
||||
|
||||
@ -702,6 +702,7 @@ async def test_topic_no_prefix(
|
||||
device_reg,
|
||||
entity_reg,
|
||||
setup_tasmota,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test detecting devices with same topic."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
@ -734,7 +735,6 @@ async def test_topic_no_prefix(
|
||||
|
||||
# Verify a repairs issue was created
|
||||
issue_id = "topic_no_prefix_00000049A3BC"
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert ("tasmota", issue_id) in issue_registry.issues
|
||||
|
||||
# Rediscover device with fixed config
|
||||
@ -753,5 +753,4 @@ async def test_topic_no_prefix(
|
||||
assert len(er.async_entries_for_device(entity_reg, device_entry.id, True)) == 1
|
||||
|
||||
# Verify the repairs issue has been removed
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert ("tasmota", issue_id) not in issue_registry.issues
|
||||
|
@ -14,8 +14,7 @@ from homeassistant.components.lock import (
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.issue_registry import async_get as async_get_issue_registry
|
||||
from homeassistant.helpers import entity_registry as er, issue_registry as ir
|
||||
|
||||
from .common import DOMAIN, assert_entities, setup_platform
|
||||
|
||||
@ -86,12 +85,11 @@ async def test_locks(
|
||||
|
||||
|
||||
async def test_speed_limit_lock(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Tests that the deprecated speed limit lock entity is correct."""
|
||||
|
||||
issue_registry = async_get_issue_registry(hass)
|
||||
|
||||
# Create the deprecated speed limit lock entity
|
||||
entity = entity_registry.async_get_or_create(
|
||||
LOCK_DOMAIN,
|
||||
|
@ -304,6 +304,7 @@ async def test_deprecation_warning(
|
||||
display_options: list[str],
|
||||
expected_warnings: list[str],
|
||||
expected_issues: list[str],
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test deprecation warning for swatch beat."""
|
||||
config = {
|
||||
@ -321,7 +322,6 @@ async def test_deprecation_warning(
|
||||
for expected_warning in expected_warnings:
|
||||
assert any(expected_warning in warning.message for warning in warnings)
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
assert len(issue_registry.issues) == len(expected_issues)
|
||||
for expected_issue in expected_issues:
|
||||
assert (DOMAIN, expected_issue) in issue_registry.issues
|
||||
|
@ -134,6 +134,7 @@ async def test_multipan_firmware_repair(
|
||||
expected_learn_more_url: str,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test creating a repair when multi-PAN firmware is installed and probed."""
|
||||
|
||||
@ -162,8 +163,6 @@ async def test_multipan_firmware_repair(
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
issue = issue_registry.async_get_issue(
|
||||
domain=DOMAIN,
|
||||
issue_id=ISSUE_WRONG_SILABS_FIRMWARE_INSTALLED,
|
||||
@ -186,7 +185,7 @@ async def test_multipan_firmware_repair(
|
||||
|
||||
|
||||
async def test_multipan_firmware_no_repair_on_probe_failure(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test that a repair is not created when multi-PAN firmware cannot be probed."""
|
||||
|
||||
@ -212,7 +211,6 @@ async def test_multipan_firmware_no_repair_on_probe_failure(
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
# No repair is created
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(
|
||||
domain=DOMAIN,
|
||||
issue_id=ISSUE_WRONG_SILABS_FIRMWARE_INSTALLED,
|
||||
@ -224,6 +222,7 @@ async def test_multipan_firmware_retry_on_probe_ezsp(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test that ZHA is reloaded when EZSP firmware is probed."""
|
||||
|
||||
@ -250,7 +249,6 @@ async def test_multipan_firmware_retry_on_probe_ezsp(
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
# No repair is created
|
||||
issue_registry = ir.async_get(hass)
|
||||
issue = issue_registry.async_get_issue(
|
||||
domain=DOMAIN,
|
||||
issue_id=ISSUE_WRONG_SILABS_FIRMWARE_INSTALLED,
|
||||
@ -299,6 +297,7 @@ async def test_inconsistent_settings_keep_new(
|
||||
config_entry: MockConfigEntry,
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
network_backup: zigpy.backups.NetworkBackup,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test inconsistent ZHA network settings: keep new settings."""
|
||||
|
||||
@ -326,8 +325,6 @@ async def test_inconsistent_settings_keep_new(
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
issue = issue_registry.async_get_issue(
|
||||
domain=DOMAIN,
|
||||
issue_id=ISSUE_INCONSISTENT_NETWORK_SETTINGS,
|
||||
@ -379,6 +376,7 @@ async def test_inconsistent_settings_restore_old(
|
||||
config_entry: MockConfigEntry,
|
||||
mock_zigpy_connect: ControllerApplication,
|
||||
network_backup: zigpy.backups.NetworkBackup,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test inconsistent ZHA network settings: restore last backup."""
|
||||
|
||||
@ -406,8 +404,6 @@ async def test_inconsistent_settings_restore_old(
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
issue_registry = ir.async_get(hass)
|
||||
|
||||
issue = issue_registry.async_get_issue(
|
||||
domain=DOMAIN,
|
||||
issue_id=ISSUE_INCONSISTENT_NETWORK_SETTINGS,
|
||||
|
@ -748,7 +748,9 @@ async def test_update_addon(
|
||||
assert update_addon.call_count == update_calls
|
||||
|
||||
|
||||
async def test_issue_registry(hass: HomeAssistant, client, version_state) -> None:
|
||||
async def test_issue_registry(
|
||||
hass: HomeAssistant, client, version_state, issue_registry: ir.IssueRegistry
|
||||
) -> None:
|
||||
"""Test issue registry."""
|
||||
device = "/test"
|
||||
network_key = "abc123"
|
||||
@ -774,8 +776,7 @@ async def test_issue_registry(hass: HomeAssistant, client, version_state) -> Non
|
||||
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
issue_reg = ir.async_get(hass)
|
||||
assert issue_reg.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
assert issue_registry.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
|
||||
async def connect():
|
||||
await asyncio.sleep(0)
|
||||
@ -786,7 +787,7 @@ async def test_issue_registry(hass: HomeAssistant, client, version_state) -> Non
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
assert not issue_reg.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
assert not issue_registry.async_get_issue(DOMAIN, "invalid_server_version")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user