mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Migrate legacy Ecobee notify service (#115592)
* Migrate legacy Ecobee notify service * Correct comment * Update homeassistant/components/ecobee/notify.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Use version to check latest entry being used * Use 6 months of deprecation * Add repair flow tests * Only allow migrate_notify fix flow * Simplify repair flow * Use ecobee data to refrence entry * Make entry attrubute puiblic * Use hass.data ro retrieve entry. * Only register issue when legacy service when it is use * Remove backslash * Use ws_client.send_json_auto_id * Cleanup * Import domain from notify integration * Apply suggestions from code review Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update dependencies * Use Issue_registry fixture * remove `update_before_add` flag * Update homeassistant/components/ecobee/notify.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/ecobee/notify.py * Update tests/components/ecobee/conftest.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Fix typo and import --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
57
tests/components/ecobee/test_notify.py
Normal file
57
tests/components/ecobee/test_notify.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""Test Ecobee notify service."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from homeassistant.components.ecobee import DOMAIN
|
||||
from homeassistant.components.notify import (
|
||||
DOMAIN as NOTIFY_DOMAIN,
|
||||
SERVICE_SEND_MESSAGE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
|
||||
from .common import setup_platform
|
||||
|
||||
THERMOSTAT_ID = 0
|
||||
|
||||
|
||||
async def test_notify_entity_service(
|
||||
hass: HomeAssistant,
|
||||
mock_ecobee: MagicMock,
|
||||
) -> None:
|
||||
"""Test the notify entity service."""
|
||||
await setup_platform(hass, NOTIFY_DOMAIN)
|
||||
|
||||
entity_id = "notify.ecobee"
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert hass.services.has_service(NOTIFY_DOMAIN, SERVICE_SEND_MESSAGE)
|
||||
await hass.services.async_call(
|
||||
NOTIFY_DOMAIN,
|
||||
SERVICE_SEND_MESSAGE,
|
||||
service_data={"entity_id": entity_id, "message": "It is too cold!"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
mock_ecobee.send_message.assert_called_with(THERMOSTAT_ID, "It is too cold!")
|
||||
|
||||
|
||||
async def test_legacy_notify_service(
|
||||
hass: HomeAssistant,
|
||||
mock_ecobee: MagicMock,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test the legacy notify service."""
|
||||
await setup_platform(hass, NOTIFY_DOMAIN)
|
||||
|
||||
assert hass.services.has_service(NOTIFY_DOMAIN, DOMAIN)
|
||||
await hass.services.async_call(
|
||||
NOTIFY_DOMAIN,
|
||||
DOMAIN,
|
||||
service_data={"message": "It is too cold!", "target": THERMOSTAT_ID},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
mock_ecobee.send_message.assert_called_with(THERMOSTAT_ID, "It is too cold!")
|
||||
mock_ecobee.send_message.reset_mock()
|
||||
assert len(issue_registry.issues) == 1
|
||||
Reference in New Issue
Block a user