Bump hass-nabucasa from 0.74.0 to 0.75.1 (#105958)
* Bump hass-nabucasa from 0.74.0 to 0.75.1 * Force sorting of parametrized test * Simplify async_create_issue.severity * use fixtures
This commit is contained in:
parent
48740e6b05
commit
5b4000e759
7 changed files with 88 additions and 6 deletions
|
@ -6,7 +6,7 @@ from datetime import datetime
|
|||
from http import HTTPStatus
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
|
||||
import aiohttp
|
||||
from hass_nabucasa.client import CloudClient as Interface
|
||||
|
@ -22,12 +22,18 @@ from homeassistant.core import Context, HassJob, HomeAssistant, callback
|
|||
from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.util.aiohttp import MockRequest, serialize_response
|
||||
|
||||
from . import alexa_config, google_config
|
||||
from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN
|
||||
from .prefs import CloudPreferences
|
||||
|
||||
VALID_REPAIR_TRANSLATION_KEYS = {
|
||||
"warn_bad_custom_domain_configuration",
|
||||
"reset_bad_custom_domain_configuration",
|
||||
}
|
||||
|
||||
|
||||
class CloudClient(Interface):
|
||||
"""Interface class for Home Assistant Cloud."""
|
||||
|
@ -302,3 +308,24 @@ class CloudClient(Interface):
|
|||
) -> None:
|
||||
"""Update local list of cloudhooks."""
|
||||
await self._prefs.async_update(cloudhooks=data)
|
||||
|
||||
async def async_create_repair_issue(
|
||||
self,
|
||||
identifier: str,
|
||||
translation_key: str,
|
||||
*,
|
||||
placeholders: dict[str, str] | None = None,
|
||||
severity: Literal["error", "warning"] = "warning",
|
||||
) -> None:
|
||||
"""Create a repair issue."""
|
||||
if translation_key not in VALID_REPAIR_TRANSLATION_KEYS:
|
||||
raise ValueError(f"Invalid translation key {translation_key}")
|
||||
async_create_issue(
|
||||
hass=self._hass,
|
||||
domain=DOMAIN,
|
||||
issue_id=identifier,
|
||||
translation_key=translation_key,
|
||||
translation_placeholders=placeholders,
|
||||
severity=IssueSeverity(severity),
|
||||
is_fixable=False,
|
||||
)
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
"integration_type": "system",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["hass_nabucasa"],
|
||||
"requirements": ["hass-nabucasa==0.74.0"]
|
||||
"requirements": ["hass-nabucasa==0.75.1"]
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@
|
|||
"operation_took_too_long": "The operation took too long. Please try again later."
|
||||
}
|
||||
}
|
||||
},
|
||||
"warn_bad_custom_domain_configuration": {
|
||||
"title": "Detected wrong custom domain configuration",
|
||||
"description": "The DNS configuration for your custom domain ({custom_domains}) is not correct. Please check the DNS configuration of your domain and make sure it points to the correct CNAME."
|
||||
},
|
||||
"reset_bad_custom_domain_configuration": {
|
||||
"title": "Custom domain ignored",
|
||||
"description": "The DNS configuration for your custom domain ({custom_domains}) is not correct. This domain has now been ignored and will not be used for Home Assistant Cloud. If you want to use this domain, please fix the DNS configuration and restart Home Assistant. If you do not need this anymore, you can remove it from the account page."
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
|
|
|
@ -24,7 +24,7 @@ fnv-hash-fast==0.5.0
|
|||
ha-av==10.1.1
|
||||
ha-ffmpeg==3.1.0
|
||||
habluetooth==1.0.0
|
||||
hass-nabucasa==0.74.0
|
||||
hass-nabucasa==0.75.1
|
||||
hassil==1.5.1
|
||||
home-assistant-bluetooth==1.11.0
|
||||
home-assistant-frontend==20231208.2
|
||||
|
|
|
@ -992,7 +992,7 @@ habitipy==0.2.0
|
|||
habluetooth==1.0.0
|
||||
|
||||
# homeassistant.components.cloud
|
||||
hass-nabucasa==0.74.0
|
||||
hass-nabucasa==0.75.1
|
||||
|
||||
# homeassistant.components.splunk
|
||||
hass-splunk==0.1.1
|
||||
|
|
|
@ -791,7 +791,7 @@ habitipy==0.2.0
|
|||
habluetooth==1.0.0
|
||||
|
||||
# homeassistant.components.cloud
|
||||
hass-nabucasa==0.74.0
|
||||
hass-nabucasa==0.75.1
|
||||
|
||||
# homeassistant.components.conversation
|
||||
hassil==1.5.1
|
||||
|
|
|
@ -7,7 +7,10 @@ from aiohttp import web
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.cloud import DOMAIN
|
||||
from homeassistant.components.cloud.client import CloudClient
|
||||
from homeassistant.components.cloud.client import (
|
||||
VALID_REPAIR_TRANSLATION_KEYS,
|
||||
CloudClient,
|
||||
)
|
||||
from homeassistant.components.cloud.const import (
|
||||
PREF_ALEXA_REPORT_STATE,
|
||||
PREF_ENABLE_ALEXA,
|
||||
|
@ -21,6 +24,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.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
@ -381,3 +385,46 @@ async def test_cloud_connection_info(hass: HomeAssistant) -> None:
|
|||
"version": HA_VERSION,
|
||||
"instance_id": "12345678901234567890",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"translation_key",
|
||||
sorted(VALID_REPAIR_TRANSLATION_KEYS),
|
||||
)
|
||||
async def test_async_create_repair_issue_known(
|
||||
cloud: MagicMock,
|
||||
mock_cloud_setup: None,
|
||||
issue_registry: IssueRegistry,
|
||||
translation_key: str,
|
||||
) -> None:
|
||||
"""Test create repair issue for known repairs."""
|
||||
identifier = f"test_identifier_{translation_key}"
|
||||
await cloud.client.async_create_repair_issue(
|
||||
identifier=identifier,
|
||||
translation_key=translation_key,
|
||||
placeholders={"custom_domains": "example.com"},
|
||||
severity="warning",
|
||||
)
|
||||
issue = issue_registry.async_get_issue(domain=DOMAIN, issue_id=identifier)
|
||||
assert issue is not None
|
||||
|
||||
|
||||
async def test_async_create_repair_issue_unknown(
|
||||
cloud: MagicMock,
|
||||
mock_cloud_setup: None,
|
||||
issue_registry: IssueRegistry,
|
||||
) -> None:
|
||||
"""Test not creating repair issue for unknown repairs."""
|
||||
identifier = "abc123"
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="Invalid translation key unknown_translation_key",
|
||||
):
|
||||
await cloud.client.async_create_repair_issue(
|
||||
identifier=identifier,
|
||||
translation_key="unknown_translation_key",
|
||||
placeholders={"custom_domains": "example.com"},
|
||||
severity="error",
|
||||
)
|
||||
issue = issue_registry.async_get_issue(domain=DOMAIN, issue_id=identifier)
|
||||
assert issue is None
|
||||
|
|
Loading…
Add table
Reference in a new issue