parent
4c3e98b77c
commit
080ce51ed9
|
@ -5,21 +5,16 @@ import logging
|
|||
from typing import Any
|
||||
|
||||
from pushover_complete import BadAPIRequestError, PushoverAPI
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_DATA,
|
||||
ATTR_TARGET,
|
||||
ATTR_TITLE,
|
||||
ATTR_TITLE_DEFAULT,
|
||||
PLATFORM_SCHEMA,
|
||||
BaseNotificationService,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from .const import (
|
||||
|
@ -40,11 +35,6 @@ from .const import (
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{vol.Required(CONF_USER_KEY): cv.string, vol.Required(CONF_API_KEY): cv.string}
|
||||
)
|
||||
|
||||
|
||||
async def async_get_service(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
|
@ -52,17 +42,7 @@ async def async_get_service(
|
|||
) -> PushoverNotificationService | None:
|
||||
"""Get the Pushover notification service."""
|
||||
if discovery_info is None:
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"removed_yaml",
|
||||
breaks_in_ha_version="2022.11.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="removed_yaml",
|
||||
)
|
||||
return None
|
||||
|
||||
pushover_api: PushoverAPI = hass.data[DOMAIN][discovery_info["entry_id"]]
|
||||
return PushoverNotificationService(
|
||||
hass, pushover_api, discovery_info[CONF_USER_KEY]
|
||||
|
|
|
@ -24,11 +24,5 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"removed_yaml": {
|
||||
"title": "The Pushover YAML configuration has been removed",
|
||||
"description": "Configuring Pushover using YAML has been removed.\n\nYour existing YAML configuration is not used by Home Assistant.\n\nRemove the Pushover YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,13 @@ from pushover_complete import BadAPIRequestError
|
|||
import pytest
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
||||
from homeassistant.components.pushover.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import MOCK_CONFIG
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.repairs import get_repairs
|
||||
from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@pytest.fixture(autouse=False)
|
||||
|
@ -27,33 +23,6 @@ def mock_pushover():
|
|||
yield mock_generic_post
|
||||
|
||||
|
||||
async def test_setup(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
mock_pushover: MagicMock,
|
||||
) -> None:
|
||||
"""Test integration failed due to an error."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
NOTIFY_DOMAIN,
|
||||
{
|
||||
NOTIFY_DOMAIN: [
|
||||
{
|
||||
"name": "Pushover",
|
||||
"platform": "pushover",
|
||||
"api_key": "MYAPIKEY",
|
||||
"user_key": "MYUSERKEY",
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert not hass.config_entries.async_entries(DOMAIN)
|
||||
issues = await get_repairs(hass, hass_ws_client)
|
||||
assert len(issues) == 1
|
||||
assert issues[0]["issue_id"] == "removed_yaml"
|
||||
|
||||
|
||||
async def test_async_setup_entry_success(
|
||||
hass: HomeAssistant, mock_pushover: MagicMock
|
||||
) -> None:
|
||||
|
|
Loading…
Reference in New Issue