Deprecate mailbox platform (#110930)
This commit is contained in:
parent
8fb542917b
commit
d7fb949994
10 changed files with 118 additions and 2 deletions
|
@ -93,7 +93,7 @@ omit =
|
|||
homeassistant/components/aseko_pool_live/entity.py
|
||||
homeassistant/components/aseko_pool_live/sensor.py
|
||||
homeassistant/components/asterisk_cdr/mailbox.py
|
||||
homeassistant/components/asterisk_mbox/*
|
||||
homeassistant/components/asterisk_mbox/mailbox.py
|
||||
homeassistant/components/aten_pe/*
|
||||
homeassistant/components/atome/*
|
||||
homeassistant/components/aurora/__init__.py
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send, dispatcher_connect
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -50,6 +51,21 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
password: str = conf[CONF_PASSWORD]
|
||||
|
||||
hass.data[DOMAIN] = AsteriskData(hass, host, port, password, config)
|
||||
create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_integration",
|
||||
breaks_in_ha_version="2024.9.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_integration",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Asterisk Voicemail",
|
||||
"mailbox": "mailbox",
|
||||
},
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
|
8
homeassistant/components/asterisk_mbox/strings.json
Normal file
8
homeassistant/components/asterisk_mbox/strings.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"issues": {
|
||||
"deprecated_integration": {
|
||||
"title": "The {integration_title} is being removed",
|
||||
"description": "{integration_title} is being removed as the `{mailbox}` platform is being removed and {integration_title} supports no other platforms. Remove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ from homeassistant.exceptions import HomeAssistantError
|
|||
from homeassistant.helpers import config_validation as cv, discovery
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.setup import async_prepare_setup_platform
|
||||
|
||||
|
@ -61,6 +62,23 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
_LOGGER.error("Unknown mailbox platform specified")
|
||||
return
|
||||
|
||||
if p_type not in ["asterisk_cdr", "asterisk_mbox", "demo"]:
|
||||
# Asterisk integration will raise a repair issue themselves
|
||||
# For demo we don't create one
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
f"deprecated_mailbox_{p_type}",
|
||||
breaks_in_ha_version="2024.9.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_mailbox_integration",
|
||||
translation_placeholders={
|
||||
"integration_domain": p_type,
|
||||
},
|
||||
)
|
||||
|
||||
_LOGGER.info("Setting up %s.%s", DOMAIN, p_type)
|
||||
mailbox = None
|
||||
try:
|
||||
|
|
|
@ -1 +1,9 @@
|
|||
{ "title": "Mailbox" }
|
||||
{
|
||||
"title": "Mailbox",
|
||||
"issues": {
|
||||
"deprecated_mailbox": {
|
||||
"title": "The mailbox platform is being removed",
|
||||
"description": "The mailbox platform is being removed. Please report it to the author of the '{integration_domain}' custom integration."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -433,6 +433,9 @@ aranet4==2.2.2
|
|||
# homeassistant.components.arcam_fmj
|
||||
arcam-fmj==1.4.0
|
||||
|
||||
# homeassistant.components.asterisk_mbox
|
||||
asterisk_mbox==0.5.0
|
||||
|
||||
# homeassistant.components.dlna_dmr
|
||||
# homeassistant.components.dlna_dms
|
||||
# homeassistant.components.samsungtv
|
||||
|
|
1
tests/components/asterisk_mbox/__init__.py
Normal file
1
tests/components/asterisk_mbox/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
"""Tests for the asterisk component."""
|
12
tests/components/asterisk_mbox/const.py
Normal file
12
tests/components/asterisk_mbox/const.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
"""Asterisk tests constants."""
|
||||
|
||||
from homeassistant.components.asterisk_mbox import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
||||
|
||||
CONFIG = {
|
||||
DOMAIN: {
|
||||
CONF_HOST: "localhost",
|
||||
CONF_PASSWORD: "password",
|
||||
CONF_PORT: 1234,
|
||||
}
|
||||
}
|
35
tests/components/asterisk_mbox/test_init.py
Normal file
35
tests/components/asterisk_mbox/test_init.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
"""Test mailbox."""
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.asterisk_mbox import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .const import CONFIG
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client() -> Generator[Mock, None, None]:
|
||||
"""Mock client."""
|
||||
with patch(
|
||||
"homeassistant.components.asterisk_mbox.asteriskClient", autospec=True
|
||||
) as client:
|
||||
yield client
|
||||
|
||||
|
||||
async def test_repair_issue_is_created(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
client: Mock,
|
||||
) -> None:
|
||||
"""Test repair issue is created."""
|
||||
assert await async_setup_component(hass, DOMAIN, CONFIG)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
DOMAIN,
|
||||
"deprecated_integration",
|
||||
) in issue_registry.issues
|
|
@ -10,6 +10,7 @@ import pytest
|
|||
from homeassistant.bootstrap import async_setup_component
|
||||
import homeassistant.components.mailbox as mailbox
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
@ -207,3 +208,17 @@ async def test_delete_from_invalid_mailbox(mock_http_client: TestClient) -> None
|
|||
|
||||
req = await mock_http_client.delete(url)
|
||||
assert req.status == HTTPStatus.NOT_FOUND
|
||||
|
||||
|
||||
async def test_repair_issue_is_created(
|
||||
hass: HomeAssistant, issue_registry: ir.IssueRegistry, mock_mailbox: None
|
||||
) -> None:
|
||||
"""Test repair issue is created."""
|
||||
assert await async_setup_component(
|
||||
hass, mailbox.DOMAIN, {mailbox.DOMAIN: {"platform": "test"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
mailbox.DOMAIN,
|
||||
"deprecated_mailbox_test",
|
||||
) in issue_registry.issues
|
||||
|
|
Loading…
Add table
Reference in a new issue