From 39dc9aa1795c25599cc794faf216d0b4ca950fd4 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 20 Jul 2022 12:06:52 +0200 Subject: [PATCH] Rename Resolution Center -> Repairs (#75486) --- .strict-typing | 2 +- CODEOWNERS | 4 +- .../__init__.py | 8 +-- homeassistant/components/repairs/const.py | 3 + .../issue_handler.py | 38 ++++++------- .../issue_registry.py | 2 +- .../manifest.json | 6 +- .../{resolution_center => repairs}/models.py | 10 ++-- .../websocket_api.py | 28 ++++----- .../components/resolution_center/const.py | 3 - mypy.ini | 2 +- script/hassfest/manifest.py | 2 +- tests/components/repairs/__init__.py | 1 + .../test_init.py | 51 ++++++++--------- .../test_issue_registry.py | 11 ++-- .../test_websocket_api.py | 57 +++++++++---------- .../components/resolution_center/__init__.py | 1 - 17 files changed, 106 insertions(+), 123 deletions(-) rename homeassistant/components/{resolution_center => repairs}/__init__.py (66%) create mode 100644 homeassistant/components/repairs/const.py rename homeassistant/components/{resolution_center => repairs}/issue_handler.py (75%) rename homeassistant/components/{resolution_center => repairs}/issue_registry.py (99%) rename homeassistant/components/{resolution_center => repairs}/manifest.json (65%) rename homeassistant/components/{resolution_center => repairs}/models.py (69%) rename homeassistant/components/{resolution_center => repairs}/websocket_api.py (83%) delete mode 100644 homeassistant/components/resolution_center/const.py create mode 100644 tests/components/repairs/__init__.py rename tests/components/{resolution_center => repairs}/test_init.py (87%) rename tests/components/{resolution_center => repairs}/test_issue_registry.py (91%) rename tests/components/{resolution_center => repairs}/test_websocket_api.py (86%) delete mode 100644 tests/components/resolution_center/__init__.py diff --git a/.strict-typing b/.strict-typing index 46d85aa1ec2..7616589a7b5 100644 --- a/.strict-typing +++ b/.strict-typing @@ -197,7 +197,7 @@ homeassistant.components.recollect_waste.* homeassistant.components.recorder.* homeassistant.components.remote.* homeassistant.components.renault.* -homeassistant.components.resolution_center.* +homeassistant.components.repairs.* homeassistant.components.rhasspy.* homeassistant.components.ridwell.* homeassistant.components.rituals_perfume_genie.* diff --git a/CODEOWNERS b/CODEOWNERS index fd271e6adc6..dbbb21f0d6c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -859,9 +859,9 @@ build.json @home-assistant/supervisor /tests/components/remote/ @home-assistant/core /homeassistant/components/renault/ @epenet /tests/components/renault/ @epenet +/homeassistant/components/repairs/ @home-assistant/core +/tests/components/repairs/ @home-assistant/core /homeassistant/components/repetier/ @MTrab @ShadowBr0ther -/homeassistant/components/resolution_center/ @home-assistant/core -/tests/components/resolution_center/ @home-assistant/core /homeassistant/components/rflink/ @javicalle /tests/components/rflink/ @javicalle /homeassistant/components/rfxtrx/ @danielhiversen @elupus @RobBie1221 diff --git a/homeassistant/components/resolution_center/__init__.py b/homeassistant/components/repairs/__init__.py similarity index 66% rename from homeassistant/components/resolution_center/__init__.py rename to homeassistant/components/repairs/__init__.py index 7d0cd8416c3..5a85d1999d0 100644 --- a/homeassistant/components/resolution_center/__init__.py +++ b/homeassistant/components/repairs/__init__.py @@ -1,4 +1,4 @@ -"""The resolution center integration.""" +"""The repairs integration.""" from __future__ import annotations from homeassistant.core import HomeAssistant @@ -6,14 +6,14 @@ from homeassistant.helpers.typing import ConfigType from . import issue_handler, websocket_api from .const import DOMAIN -from .issue_handler import ResolutionCenterFlow, async_create_issue, async_delete_issue +from .issue_handler import RepairsFlow, async_create_issue, async_delete_issue from .issue_registry import async_load as async_load_issue_registry -__all__ = ["DOMAIN", "ResolutionCenterFlow", "async_create_issue", "async_delete_issue"] +__all__ = ["DOMAIN", "RepairsFlow", "async_create_issue", "async_delete_issue"] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up Resolution Center.""" + """Set up Repairs.""" hass.data[DOMAIN] = {} issue_handler.async_setup(hass) diff --git a/homeassistant/components/repairs/const.py b/homeassistant/components/repairs/const.py new file mode 100644 index 00000000000..cddc5edcffd --- /dev/null +++ b/homeassistant/components/repairs/const.py @@ -0,0 +1,3 @@ +"""Constants for the Repairs integration.""" + +DOMAIN = "repairs" diff --git a/homeassistant/components/resolution_center/issue_handler.py b/homeassistant/components/repairs/issue_handler.py similarity index 75% rename from homeassistant/components/resolution_center/issue_handler.py rename to homeassistant/components/repairs/issue_handler.py index 78085e2cec6..ff23c1c70a4 100644 --- a/homeassistant/components/resolution_center/issue_handler.py +++ b/homeassistant/components/repairs/issue_handler.py @@ -1,4 +1,4 @@ -"""The resolution center integration.""" +"""The repairs integration.""" from __future__ import annotations from typing import Any @@ -14,11 +14,11 @@ from homeassistant.helpers.integration_platform import ( from .const import DOMAIN from .issue_registry import async_get as async_get_issue_registry -from .models import IssueSeverity, ResolutionCenterFlow, ResolutionCenterProtocol +from .models import IssueSeverity, RepairsFlow, RepairsProtocol -class ResolutionCenterFlowManager(data_entry_flow.FlowManager): - """Manage resolution center flows.""" +class RepairsFlowManager(data_entry_flow.FlowManager): + """Manage repairs flows.""" async def async_create_flow( self, @@ -26,14 +26,12 @@ class ResolutionCenterFlowManager(data_entry_flow.FlowManager): *, context: dict[str, Any] | None = None, data: dict[str, Any] | None = None, - ) -> ResolutionCenterFlow: - """Create a flow. platform is a resolution center module.""" + ) -> RepairsFlow: + """Create a flow. platform is a repairs module.""" if "platforms" not in self.hass.data[DOMAIN]: - await async_process_resolution_center_platforms(self.hass) + await async_process_repairs_platforms(self.hass) - platforms: dict[str, ResolutionCenterProtocol] = self.hass.data[DOMAIN][ - "platforms" - ] + platforms: dict[str, RepairsProtocol] = self.hass.data[DOMAIN]["platforms"] if handler_key not in platforms: raise data_entry_flow.UnknownHandler platform = platforms[handler_key] @@ -60,25 +58,23 @@ class ResolutionCenterFlowManager(data_entry_flow.FlowManager): @callback def async_setup(hass: HomeAssistant) -> None: - """Initialize resolution center.""" - hass.data[DOMAIN]["flow_manager"] = ResolutionCenterFlowManager(hass) + """Initialize repairs.""" + hass.data[DOMAIN]["flow_manager"] = RepairsFlowManager(hass) -async def async_process_resolution_center_platforms(hass: HomeAssistant) -> None: - """Start processing resolution center platforms.""" +async def async_process_repairs_platforms(hass: HomeAssistant) -> None: + """Start processing repairs platforms.""" hass.data[DOMAIN]["platforms"] = {} - await async_process_integration_platforms( - hass, DOMAIN, _register_resolution_center_platform - ) + await async_process_integration_platforms(hass, DOMAIN, _register_repairs_platform) -async def _register_resolution_center_platform( - hass: HomeAssistant, integration_domain: str, platform: ResolutionCenterProtocol +async def _register_repairs_platform( + hass: HomeAssistant, integration_domain: str, platform: RepairsProtocol ) -> None: - """Register a resolution center platform.""" + """Register a repairs platform.""" if not hasattr(platform, "async_create_fix_flow"): - raise HomeAssistantError(f"Invalid resolution center platform {platform}") + raise HomeAssistantError(f"Invalid repairs platform {platform}") hass.data[DOMAIN]["platforms"][integration_domain] = platform diff --git a/homeassistant/components/resolution_center/issue_registry.py b/homeassistant/components/repairs/issue_registry.py similarity index 99% rename from homeassistant/components/resolution_center/issue_registry.py rename to homeassistant/components/repairs/issue_registry.py index e398d58b3e0..c1eda0d53be 100644 --- a/homeassistant/components/resolution_center/issue_registry.py +++ b/homeassistant/components/repairs/issue_registry.py @@ -13,7 +13,7 @@ import homeassistant.util.dt as dt_util from .models import IssueSeverity DATA_REGISTRY = "issue_registry" -STORAGE_KEY = "resolution_center.issue_registry" +STORAGE_KEY = "repairs.issue_registry" STORAGE_VERSION = 1 SAVE_DELAY = 10 diff --git a/homeassistant/components/resolution_center/manifest.json b/homeassistant/components/repairs/manifest.json similarity index 65% rename from homeassistant/components/resolution_center/manifest.json rename to homeassistant/components/repairs/manifest.json index 4b8c1bb2506..f2013743a05 100644 --- a/homeassistant/components/resolution_center/manifest.json +++ b/homeassistant/components/repairs/manifest.json @@ -1,8 +1,8 @@ { - "domain": "resolution_center", - "name": "Resolution Center", + "domain": "repairs", + "name": "Repairs", "config_flow": false, - "documentation": "https://www.home-assistant.io/integrations/resolution_center", + "documentation": "https://www.home-assistant.io/integrations/repairs", "codeowners": ["@home-assistant/core"], "dependencies": ["http"] } diff --git a/homeassistant/components/resolution_center/models.py b/homeassistant/components/repairs/models.py similarity index 69% rename from homeassistant/components/resolution_center/models.py rename to homeassistant/components/repairs/models.py index 12e2f4e73f3..2a6eeb15269 100644 --- a/homeassistant/components/resolution_center/models.py +++ b/homeassistant/components/repairs/models.py @@ -1,4 +1,4 @@ -"""Models for Resolution Center.""" +"""Models for Repairs.""" from __future__ import annotations from typing import Protocol @@ -16,14 +16,14 @@ class IssueSeverity(StrEnum): WARNING = "warning" -class ResolutionCenterFlow(data_entry_flow.FlowHandler): +class RepairsFlow(data_entry_flow.FlowHandler): """Handle a flow for fixing an issue.""" -class ResolutionCenterProtocol(Protocol): - """Define the format of resolution center platforms.""" +class RepairsProtocol(Protocol): + """Define the format of repairs platforms.""" async def async_create_fix_flow( self, hass: HomeAssistant, issue_id: str - ) -> ResolutionCenterFlow: + ) -> RepairsFlow: """Create a flow to fix a fixable issue.""" diff --git a/homeassistant/components/resolution_center/websocket_api.py b/homeassistant/components/repairs/websocket_api.py similarity index 83% rename from homeassistant/components/resolution_center/websocket_api.py rename to homeassistant/components/repairs/websocket_api.py index e111c2b3e50..2e4e166f3e9 100644 --- a/homeassistant/components/resolution_center/websocket_api.py +++ b/homeassistant/components/repairs/websocket_api.py @@ -1,4 +1,4 @@ -"""The resolution center websocket API.""" +"""The repairs websocket API.""" from __future__ import annotations import dataclasses @@ -26,22 +26,18 @@ from .issue_registry import async_get as async_get_issue_registry @callback def async_setup(hass: HomeAssistant) -> None: - """Set up the resolution center websocket API.""" + """Set up the repairs websocket API.""" websocket_api.async_register_command(hass, ws_ignore_issue) websocket_api.async_register_command(hass, ws_list_issues) - hass.http.register_view( - ResolutionCenterFlowIndexView(hass.data[DOMAIN]["flow_manager"]) - ) - hass.http.register_view( - ResolutionCenterFlowResourceView(hass.data[DOMAIN]["flow_manager"]) - ) + hass.http.register_view(RepairsFlowIndexView(hass.data[DOMAIN]["flow_manager"])) + hass.http.register_view(RepairsFlowResourceView(hass.data[DOMAIN]["flow_manager"])) @callback @websocket_api.websocket_command( { - vol.Required("type"): "resolution_center/ignore_issue", + vol.Required("type"): "repairs/ignore_issue", vol.Required("domain"): str, vol.Required("issue_id"): str, vol.Required("ignore"): bool, @@ -58,7 +54,7 @@ def ws_ignore_issue( @websocket_api.websocket_command( { - vol.Required("type"): "resolution_center/list_issues", + vol.Required("type"): "repairs/list_issues", } ) @callback @@ -82,11 +78,11 @@ def ws_list_issues( connection.send_result(msg["id"], {"issues": issues}) -class ResolutionCenterFlowIndexView(FlowManagerIndexView): +class RepairsFlowIndexView(FlowManagerIndexView): """View to create issue fix flows.""" - url = "/api/resolution_center/issues/fix" - name = "api:resolution_center:issues:fix" + url = "/api/repairs/issues/fix" + name = "api:repairs:issues:fix" @RequestDataValidator( vol.Schema( @@ -119,11 +115,11 @@ class ResolutionCenterFlowIndexView(FlowManagerIndexView): return self.json(result) # pylint: disable=arguments-differ -class ResolutionCenterFlowResourceView(FlowManagerResourceView): +class RepairsFlowResourceView(FlowManagerResourceView): """View to interact with the option flow manager.""" - url = "/api/resolution_center/issues/fix/{flow_id}" - name = "api:resolution_center:issues:fix:resource" + url = "/api/repairs/issues/fix/{flow_id}" + name = "api:repairs:issues:fix:resource" async def get(self, request: web.Request, flow_id: str) -> web.Response: """Get the current state of a data_entry_flow.""" diff --git a/homeassistant/components/resolution_center/const.py b/homeassistant/components/resolution_center/const.py deleted file mode 100644 index 46d020e5118..00000000000 --- a/homeassistant/components/resolution_center/const.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Constants for the Resolution Center integration.""" - -DOMAIN = "resolution_center" diff --git a/mypy.ini b/mypy.ini index 04b76dfea0f..84bc6ae00b0 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1898,7 +1898,7 @@ no_implicit_optional = true warn_return_any = true warn_unreachable = true -[mypy-homeassistant.components.resolution_center.*] +[mypy-homeassistant.components.repairs.*] check_untyped_defs = true disallow_incomplete_defs = true disallow_subclassing_any = true diff --git a/script/hassfest/manifest.py b/script/hassfest/manifest.py index 9c1bd0a63f3..129899cff11 100644 --- a/script/hassfest/manifest.py +++ b/script/hassfest/manifest.py @@ -80,7 +80,7 @@ NO_IOT_CLASS = [ "proxy", "python_script", "raspberry_pi", - "resolution_center", + "repairs", "safe_mode", "script", "search", diff --git a/tests/components/repairs/__init__.py b/tests/components/repairs/__init__.py new file mode 100644 index 00000000000..b0d26f49ee4 --- /dev/null +++ b/tests/components/repairs/__init__.py @@ -0,0 +1 @@ +"""Tests for the repairs integration.""" diff --git a/tests/components/resolution_center/test_init.py b/tests/components/repairs/test_init.py similarity index 87% rename from tests/components/resolution_center/test_init.py rename to tests/components/repairs/test_init.py index 478c2d51f7f..fbf240e740d 100644 --- a/tests/components/resolution_center/test_init.py +++ b/tests/components/repairs/test_init.py @@ -1,17 +1,14 @@ -"""Test the resolution center websocket API.""" +"""Test the repairs websocket API.""" from unittest.mock import AsyncMock, Mock from freezegun import freeze_time import pytest -from homeassistant.components.resolution_center import ( - async_create_issue, - async_delete_issue, -) -from homeassistant.components.resolution_center.const import DOMAIN -from homeassistant.components.resolution_center.issue_handler import ( +from homeassistant.components.repairs import async_create_issue, async_delete_issue +from homeassistant.components.repairs.const import DOMAIN +from homeassistant.components.repairs.issue_handler import ( async_ignore_issue, - async_process_resolution_center_platforms, + async_process_repairs_platforms, ) from homeassistant.const import __version__ as ha_version from homeassistant.core import HomeAssistant @@ -27,7 +24,7 @@ async def test_create_update_issue(hass: HomeAssistant, hass_ws_client) -> None: client = await hass_ws_client(hass) - await client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -69,7 +66,7 @@ async def test_create_update_issue(hass: HomeAssistant, hass_ws_client) -> None: translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 2, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 2, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -98,7 +95,7 @@ async def test_create_update_issue(hass: HomeAssistant, hass_ws_client) -> None: translation_placeholders=issues[0]["translation_placeholders"], ) - await client.send_json({"id": 3, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 3, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -144,7 +141,7 @@ async def test_create_issue_invalid_version( translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -158,7 +155,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: client = await hass_ws_client(hass) - await client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -190,7 +187,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 2, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 2, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -210,7 +207,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: with pytest.raises(KeyError): async_ignore_issue(hass, issues[0]["domain"], "no_such_issue", True) - await client.send_json({"id": 3, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 3, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -229,7 +226,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: # Ignore an existing issue async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True) - await client.send_json({"id": 4, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 4, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -248,7 +245,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: # Ignore the same issue again async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True) - await client.send_json({"id": 5, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 5, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -277,7 +274,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: translation_placeholders=issues[0]["translation_placeholders"], ) - await client.send_json({"id": 6, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 6, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -292,7 +289,7 @@ async def test_ignore_issue(hass: HomeAssistant, hass_ws_client) -> None: # Unignore the same issue async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], False) - await client.send_json({"id": 7, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 7, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -343,7 +340,7 @@ async def test_delete_issue(hass: HomeAssistant, hass_ws_client, freezer) -> Non translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -362,7 +359,7 @@ async def test_delete_issue(hass: HomeAssistant, hass_ws_client, freezer) -> Non # Delete a non-existing issue async_delete_issue(hass, issues[0]["domain"], "no_such_issue") - await client.send_json({"id": 2, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 2, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -381,7 +378,7 @@ async def test_delete_issue(hass: HomeAssistant, hass_ws_client, freezer) -> Non # Delete an existing issue async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"]) - await client.send_json({"id": 3, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 3, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -390,7 +387,7 @@ async def test_delete_issue(hass: HomeAssistant, hass_ws_client, freezer) -> Non # Delete the same issue again async_delete_issue(hass, issues[0]["domain"], issues[0]["issue_id"]) - await client.send_json({"id": 4, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 4, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -412,7 +409,7 @@ async def test_delete_issue(hass: HomeAssistant, hass_ws_client, freezer) -> Non translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 5, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 5, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -436,16 +433,16 @@ async def test_non_compliant_platform(hass: HomeAssistant, hass_ws_client) -> No hass.config.components.add("integration_without_diagnostics") mock_platform( hass, - "fake_integration.resolution_center", + "fake_integration.repairs", Mock(async_create_fix_flow=AsyncMock(return_value=True)), ) mock_platform( hass, - "integration_without_diagnostics.resolution_center", + "integration_without_diagnostics.repairs", Mock(spec=[]), ) assert await async_setup_component(hass, DOMAIN, {}) - await async_process_resolution_center_platforms(hass) + await async_process_repairs_platforms(hass) assert list(hass.data[DOMAIN]["platforms"].keys()) == ["fake_integration"] diff --git a/tests/components/resolution_center/test_issue_registry.py b/tests/components/repairs/test_issue_registry.py similarity index 91% rename from tests/components/resolution_center/test_issue_registry.py rename to tests/components/repairs/test_issue_registry.py index 854a14fc84e..1af67601581 100644 --- a/tests/components/resolution_center/test_issue_registry.py +++ b/tests/components/repairs/test_issue_registry.py @@ -1,10 +1,7 @@ -"""Test the resolution center websocket API.""" -from homeassistant.components.resolution_center import ( - async_create_issue, - issue_registry, -) -from homeassistant.components.resolution_center.const import DOMAIN -from homeassistant.components.resolution_center.issue_handler import async_ignore_issue +"""Test the repairs websocket API.""" +from homeassistant.components.repairs import async_create_issue, issue_registry +from homeassistant.components.repairs.const import DOMAIN +from homeassistant.components.repairs.issue_handler import async_ignore_issue from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component diff --git a/tests/components/resolution_center/test_websocket_api.py b/tests/components/repairs/test_websocket_api.py similarity index 86% rename from tests/components/resolution_center/test_websocket_api.py rename to tests/components/repairs/test_websocket_api.py index 044b0e9832b..388912e0adc 100644 --- a/tests/components/resolution_center/test_websocket_api.py +++ b/tests/components/repairs/test_websocket_api.py @@ -1,4 +1,4 @@ -"""Test the resolution center websocket API.""" +"""Test the repairs websocket API.""" from __future__ import annotations from http import HTTPStatus @@ -9,11 +9,8 @@ import pytest import voluptuous as vol from homeassistant import data_entry_flow -from homeassistant.components.resolution_center import ( - ResolutionCenterFlow, - async_create_issue, -) -from homeassistant.components.resolution_center.const import DOMAIN +from homeassistant.components.repairs import RepairsFlow, async_create_issue +from homeassistant.components.repairs.const import DOMAIN from homeassistant.const import __version__ as ha_version from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component @@ -49,7 +46,7 @@ async def create_issues(hass, ws_client): translation_placeholders=issue["translation_placeholders"], ) - await ws_client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await ws_client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await ws_client.receive_json() assert msg["success"] @@ -68,7 +65,7 @@ async def create_issues(hass, ws_client): return issues -class MockFixFlow(ResolutionCenterFlow): +class MockFixFlow(RepairsFlow): """Handler for an issue fixing flow.""" async def async_step_init( @@ -89,8 +86,8 @@ class MockFixFlow(ResolutionCenterFlow): @pytest.fixture(autouse=True) -async def mock_resolution_center_integration(hass): - """Mock a resolution_center integration.""" +async def mock_repairs_integration(hass): + """Mock a repairs integration.""" hass.config.components.add("fake_integration") hass.config.components.add("integration_without_diagnostics") @@ -99,12 +96,12 @@ async def mock_resolution_center_integration(hass): mock_platform( hass, - "fake_integration.resolution_center", + "fake_integration.repairs", Mock(async_create_fix_flow=AsyncMock(wraps=async_create_fix_flow)), ) mock_platform( hass, - "integration_without_diagnostics.resolution_center", + "integration_without_diagnostics.repairs", Mock(spec=[]), ) @@ -120,7 +117,7 @@ async def test_dismiss_issue(hass: HomeAssistant, hass_ws_client) -> None: await client.send_json( { "id": 2, - "type": "resolution_center/ignore_issue", + "type": "repairs/ignore_issue", "domain": "fake_integration", "issue_id": "no_such_issue", "ignore": True, @@ -132,7 +129,7 @@ async def test_dismiss_issue(hass: HomeAssistant, hass_ws_client) -> None: await client.send_json( { "id": 3, - "type": "resolution_center/ignore_issue", + "type": "repairs/ignore_issue", "domain": "fake_integration", "issue_id": "issue_1", "ignore": True, @@ -142,7 +139,7 @@ async def test_dismiss_issue(hass: HomeAssistant, hass_ws_client) -> None: assert msg["success"] assert msg["result"] is None - await client.send_json({"id": 4, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 4, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -161,7 +158,7 @@ async def test_dismiss_issue(hass: HomeAssistant, hass_ws_client) -> None: await client.send_json( { "id": 5, - "type": "resolution_center/ignore_issue", + "type": "repairs/ignore_issue", "domain": "fake_integration", "issue_id": "issue_1", "ignore": False, @@ -171,7 +168,7 @@ async def test_dismiss_issue(hass: HomeAssistant, hass_ws_client) -> None: assert msg["success"] assert msg["result"] is None - await client.send_json({"id": 6, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 6, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -200,21 +197,21 @@ async def test_fix_non_existing_issue( issues = await create_issues(hass, ws_client) - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "no_such_integration", "issue_id": "no_such_issue"} ) assert resp.status != HTTPStatus.OK - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "fake_integration", "issue_id": "no_such_issue"} ) assert resp.status != HTTPStatus.OK - await ws_client.send_json({"id": 3, "type": "resolution_center/list_issues"}) + await ws_client.send_json({"id": 3, "type": "repairs/list_issues"}) msg = await ws_client.receive_json() assert msg["success"] @@ -241,7 +238,7 @@ async def test_fix_issue(hass: HomeAssistant, hass_client, hass_ws_client) -> No await create_issues(hass, ws_client) - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "fake_integration", "issue_id": "issue_1"} ) @@ -261,7 +258,7 @@ async def test_fix_issue(hass: HomeAssistant, hass_client, hass_ws_client) -> No "type": "form", } - url = f"/api/resolution_center/issues/fix/{flow_id}" + url = f"/api/repairs/issues/fix/{flow_id}" # Test we can get the status of the flow resp2 = await client.get(url) @@ -286,7 +283,7 @@ async def test_fix_issue(hass: HomeAssistant, hass_client, hass_ws_client) -> No "version": 1, } - await ws_client.send_json({"id": 4, "type": "resolution_center/list_issues"}) + await ws_client.send_json({"id": 4, "type": "repairs/list_issues"}) msg = await ws_client.receive_json() assert msg["success"] @@ -304,7 +301,7 @@ async def test_fix_issue_unauth( client = await hass_client() - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "fake_integration", "issue_id": "issue_1"} ) @@ -324,7 +321,7 @@ async def test_get_progress_unauth( await create_issues(hass, ws_client) - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "fake_integration", "issue_id": "issue_1"} ) @@ -334,7 +331,7 @@ async def test_get_progress_unauth( hass_admin_user.groups = [] - url = f"/api/resolution_center/issues/fix/{flow_id}" + url = f"/api/repairs/issues/fix/{flow_id}" # Test we can't get the status of the flow resp = await client.get(url) assert resp.status == HTTPStatus.UNAUTHORIZED @@ -352,7 +349,7 @@ async def test_step_unauth( await create_issues(hass, ws_client) - url = "/api/resolution_center/issues/fix" + url = "/api/repairs/issues/fix" resp = await client.post( url, json={"handler": "fake_integration", "issue_id": "issue_1"} ) @@ -362,7 +359,7 @@ async def test_step_unauth( hass_admin_user.groups = [] - url = f"/api/resolution_center/issues/fix/{flow_id}" + url = f"/api/repairs/issues/fix/{flow_id}" # Test we can't get the status of the flow resp = await client.post(url) assert resp.status == HTTPStatus.UNAUTHORIZED @@ -375,7 +372,7 @@ async def test_list_issues(hass: HomeAssistant, hass_ws_client) -> None: client = await hass_ws_client(hass) - await client.send_json({"id": 1, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 1, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] @@ -417,7 +414,7 @@ async def test_list_issues(hass: HomeAssistant, hass_ws_client) -> None: translation_placeholders=issue["translation_placeholders"], ) - await client.send_json({"id": 2, "type": "resolution_center/list_issues"}) + await client.send_json({"id": 2, "type": "repairs/list_issues"}) msg = await client.receive_json() assert msg["success"] diff --git a/tests/components/resolution_center/__init__.py b/tests/components/resolution_center/__init__.py deleted file mode 100644 index a6a86bf99bc..00000000000 --- a/tests/components/resolution_center/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the resolution center integration."""