Rename Resolution Center -> Repairs (#75486)
This commit is contained in:
parent
a3b2b5c328
commit
39dc9aa179
17 changed files with 106 additions and 123 deletions
|
@ -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.*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
3
homeassistant/components/repairs/const.py
Normal file
3
homeassistant/components/repairs/const.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
"""Constants for the Repairs integration."""
|
||||
|
||||
DOMAIN = "repairs"
|
|
@ -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
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -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"]
|
||||
}
|
|
@ -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."""
|
|
@ -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."""
|
|
@ -1,3 +0,0 @@
|
|||
"""Constants for the Resolution Center integration."""
|
||||
|
||||
DOMAIN = "resolution_center"
|
2
mypy.ini
2
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
|
||||
|
|
|
@ -80,7 +80,7 @@ NO_IOT_CLASS = [
|
|||
"proxy",
|
||||
"python_script",
|
||||
"raspberry_pi",
|
||||
"resolution_center",
|
||||
"repairs",
|
||||
"safe_mode",
|
||||
"script",
|
||||
"search",
|
||||
|
|
1
tests/components/repairs/__init__.py
Normal file
1
tests/components/repairs/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
"""Tests for the repairs integration."""
|
|
@ -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"]
|
|
@ -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
|
||||
|
|
@ -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"]
|
|
@ -1 +0,0 @@
|
|||
"""Tests for the resolution center integration."""
|
Loading…
Add table
Reference in a new issue