From fd5c56fc7dfa7e2e6c1fda31828305a957b330a9 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 13 Mar 2023 09:44:20 +0100 Subject: [PATCH] Rename modules named repairs.py which are not repairs platforms (#89618) --- .../components/bayesian/binary_sensor.py | 2 +- .../bayesian/{repairs.py => issues.py} | 2 +- homeassistant/components/hassio/__init__.py | 10 ++++----- .../hassio/{repairs.py => issues.py} | 18 +++++++-------- tests/components/hassio/conftest.py | 2 +- .../{test_repairs.py => test_issues.py} | 22 +++++++++---------- 6 files changed, 28 insertions(+), 28 deletions(-) rename homeassistant/components/bayesian/{repairs.py => issues.py} (97%) rename homeassistant/components/hassio/{repairs.py => issues.py} (92%) rename tests/components/hassio/{test_repairs.py => test_issues.py} (96%) diff --git a/homeassistant/components/bayesian/binary_sensor.py b/homeassistant/components/bayesian/binary_sensor.py index 77571e1a80f..06baef1bd0e 100644 --- a/homeassistant/components/bayesian/binary_sensor.py +++ b/homeassistant/components/bayesian/binary_sensor.py @@ -60,7 +60,7 @@ from .const import ( DEFAULT_PROBABILITY_THRESHOLD, ) from .helpers import Observation -from .repairs import raise_mirrored_entries, raise_no_prob_given_false +from .issues import raise_mirrored_entries, raise_no_prob_given_false _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/bayesian/repairs.py b/homeassistant/components/bayesian/issues.py similarity index 97% rename from homeassistant/components/bayesian/repairs.py rename to homeassistant/components/bayesian/issues.py index 47d7dff6e19..fbc3a86258d 100644 --- a/homeassistant/components/bayesian/repairs.py +++ b/homeassistant/components/bayesian/issues.py @@ -1,4 +1,4 @@ -"""Helpers for generating repairs.""" +"""Helpers for generating issues.""" from __future__ import annotations from homeassistant.core import HomeAssistant diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 25f3477bff1..0f17c0b5272 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -96,7 +96,7 @@ from .handler import ( # noqa: F401 ) from .http import HassIOView from .ingress import async_setup_ingress_view -from .repairs import SupervisorRepairs +from .issues import SupervisorIssues from .websocket_api import async_load_websocket_api _LOGGER = logging.getLogger(__name__) @@ -125,7 +125,7 @@ DATA_SUPERVISOR_STATS = "hassio_supervisor_stats" DATA_ADDONS_CHANGELOGS = "hassio_addons_changelogs" DATA_ADDONS_INFO = "hassio_addons_info" DATA_ADDONS_STATS = "hassio_addons_stats" -DATA_SUPERVISOR_REPAIRS = "supervisor_repairs" +DATA_SUPERVISOR_ISSUES = "supervisor_issues" HASSIO_UPDATE_INTERVAL = timedelta(minutes=5) ADDONS_COORDINATOR = "hassio_addons_coordinator" @@ -604,9 +604,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: hass.config_entries.flow.async_init(DOMAIN, context={"source": "system"}) ) - # Start listening for problems with supervisor and making repairs - hass.data[DATA_SUPERVISOR_REPAIRS] = repairs = SupervisorRepairs(hass, hassio) - await repairs.setup() + # Start listening for problems with supervisor and making issues + hass.data[DATA_SUPERVISOR_ISSUES] = issues = SupervisorIssues(hass, hassio) + await issues.setup() return True diff --git a/homeassistant/components/hassio/repairs.py b/homeassistant/components/hassio/issues.py similarity index 92% rename from homeassistant/components/hassio/repairs.py rename to homeassistant/components/hassio/issues.py index 21120d8d522..a0d51c4806d 100644 --- a/homeassistant/components/hassio/repairs.py +++ b/homeassistant/components/hassio/issues.py @@ -70,11 +70,11 @@ UNHEALTHY_REASONS = { } -class SupervisorRepairs: - """Create repairs from supervisor events.""" +class SupervisorIssues: + """Create issues from supervisor events.""" def __init__(self, hass: HomeAssistant, client: HassIO) -> None: - """Initialize supervisor repairs.""" + """Initialize supervisor issues.""" self._hass = hass self._client = client self._unsupported_reasons: set[str] = set() @@ -87,7 +87,7 @@ class SupervisorRepairs: @unhealthy_reasons.setter def unhealthy_reasons(self, reasons: set[str]) -> None: - """Set unhealthy reasons. Create or delete repairs as necessary.""" + """Set unhealthy reasons. Create or delete issues as necessary.""" for unhealthy in reasons - self.unhealthy_reasons: if unhealthy in UNHEALTHY_REASONS: translation_key = f"unhealthy_{unhealthy}" @@ -119,7 +119,7 @@ class SupervisorRepairs: @unsupported_reasons.setter def unsupported_reasons(self, reasons: set[str]) -> None: - """Set unsupported reasons. Create or delete repairs as necessary.""" + """Set unsupported reasons. Create or delete issues as necessary.""" for unsupported in reasons - UNSUPPORTED_SKIP_REPAIR - self.unsupported_reasons: if unsupported in UNSUPPORTED_REASONS: translation_key = f"unsupported_{unsupported}" @@ -149,18 +149,18 @@ class SupervisorRepairs: await self.update() async_dispatcher_connect( - self._hass, EVENT_SUPERVISOR_EVENT, self._supervisor_events_to_repairs + self._hass, EVENT_SUPERVISOR_EVENT, self._supervisor_events_to_issues ) async def update(self) -> None: - """Update repairs from Supervisor resolution center.""" + """Update issuess from Supervisor resolution center.""" data = await self._client.get_resolution_info() self.unhealthy_reasons = set(data[ATTR_UNHEALTHY]) self.unsupported_reasons = set(data[ATTR_UNSUPPORTED]) @callback - def _supervisor_events_to_repairs(self, event: dict[str, Any]) -> None: - """Create repairs from supervisor events.""" + def _supervisor_events_to_issues(self, event: dict[str, Any]) -> None: + """Create issues from supervisor events.""" if ATTR_WS_EVENT not in event: return diff --git a/tests/components/hassio/conftest.py b/tests/components/hassio/conftest.py index 78ae9643d68..afe641405e3 100644 --- a/tests/components/hassio/conftest.py +++ b/tests/components/hassio/conftest.py @@ -52,7 +52,7 @@ def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock): "homeassistant.components.hassio.HassIO.get_ingress_panels", return_value={"panels": []}, ), patch( - "homeassistant.components.hassio.repairs.SupervisorRepairs.setup" + "homeassistant.components.hassio.issues.SupervisorIssues.setup" ), patch( "homeassistant.components.hassio.HassIO.refresh_updates" ): diff --git a/tests/components/hassio/test_repairs.py b/tests/components/hassio/test_issues.py similarity index 96% rename from tests/components/hassio/test_repairs.py rename to tests/components/hassio/test_issues.py index 8806e641a5b..5b280d0c827 100644 --- a/tests/components/hassio/test_repairs.py +++ b/tests/components/hassio/test_issues.py @@ -1,4 +1,4 @@ -"""Test repairs from supervisor issues.""" +"""Test issues from supervisor issues.""" from __future__ import annotations import os @@ -145,12 +145,12 @@ def assert_repair_in_list(issues: list[dict[str, Any]], unhealthy: bool, reason: } in issues -async def test_unhealthy_repairs( +async def test_unhealthy_issues( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, hass_ws_client: WebSocketGenerator, ) -> None: - """Test repairs added for unhealthy systems.""" + """Test issues added for unhealthy systems.""" mock_resolution_info(aioclient_mock, unhealthy=["docker", "setup"]) result = await async_setup_component(hass, "hassio", {}) @@ -166,12 +166,12 @@ async def test_unhealthy_repairs( assert_repair_in_list(msg["result"]["issues"], unhealthy=True, reason="setup") -async def test_unsupported_repairs( +async def test_unsupported_issues( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, hass_ws_client: WebSocketGenerator, ) -> None: - """Test repairs added for unsupported systems.""" + """Test issues added for unsupported systems.""" mock_resolution_info(aioclient_mock, unsupported=["content_trust", "os"]) result = await async_setup_component(hass, "hassio", {}) @@ -189,12 +189,12 @@ async def test_unsupported_repairs( assert_repair_in_list(msg["result"]["issues"], unhealthy=False, reason="os") -async def test_unhealthy_repairs_add_remove( +async def test_unhealthy_issues_add_remove( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, hass_ws_client: WebSocketGenerator, ) -> None: - """Test unhealthy repairs added and removed from dispatches.""" + """Test unhealthy issues added and removed from dispatches.""" mock_resolution_info(aioclient_mock) result = await async_setup_component(hass, "hassio", {}) @@ -245,12 +245,12 @@ async def test_unhealthy_repairs_add_remove( assert msg["result"] == {"issues": []} -async def test_unsupported_repairs_add_remove( +async def test_unsupported_issues_add_remove( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, hass_ws_client: WebSocketGenerator, ) -> None: - """Test unsupported repairs added and removed from dispatches.""" + """Test unsupported issues added and removed from dispatches.""" mock_resolution_info(aioclient_mock) result = await async_setup_component(hass, "hassio", {}) @@ -301,12 +301,12 @@ async def test_unsupported_repairs_add_remove( assert msg["result"] == {"issues": []} -async def test_reset_repairs_supervisor_restart( +async def test_reset_issues_supervisor_restart( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, hass_ws_client: WebSocketGenerator, ) -> None: - """Unsupported/unhealthy repairs reset on supervisor restart.""" + """Unsupported/unhealthy issues reset on supervisor restart.""" mock_resolution_info(aioclient_mock, unsupported=["os"], unhealthy=["docker"]) result = await async_setup_component(hass, "hassio", {})