mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Drop single-use service name constants in alexa_devices (#164151)
This commit is contained in:
@@ -16,9 +16,6 @@ from .coordinator import AmazonConfigEntry
|
||||
ATTR_TEXT_COMMAND = "text_command"
|
||||
ATTR_SOUND = "sound"
|
||||
ATTR_INFO_SKILL = "info_skill"
|
||||
SERVICE_TEXT_COMMAND = "send_text_command"
|
||||
SERVICE_SOUND_NOTIFICATION = "send_sound"
|
||||
SERVICE_INFO_SKILL = "send_info_skill"
|
||||
|
||||
SCHEMA_SOUND_SERVICE = vol.Schema(
|
||||
{
|
||||
@@ -128,17 +125,17 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
"""Set up the services for the Amazon Devices integration."""
|
||||
for service_name, method, schema in (
|
||||
(
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
async_send_sound_notification,
|
||||
SCHEMA_SOUND_SERVICE,
|
||||
),
|
||||
(
|
||||
SERVICE_TEXT_COMMAND,
|
||||
"send_text_command",
|
||||
async_send_text_command,
|
||||
SCHEMA_CUSTOM_COMMAND,
|
||||
),
|
||||
(
|
||||
SERVICE_INFO_SKILL,
|
||||
"send_info_skill",
|
||||
async_send_info_skill,
|
||||
SCHEMA_INFO_SKILL,
|
||||
),
|
||||
|
||||
@@ -10,9 +10,6 @@ from homeassistant.components.alexa_devices.services import (
|
||||
ATTR_INFO_SKILL,
|
||||
ATTR_SOUND,
|
||||
ATTR_TEXT_COMMAND,
|
||||
SERVICE_INFO_SKILL,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
SERVICE_TEXT_COMMAND,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_DEVICE_ID
|
||||
@@ -35,9 +32,9 @@ async def test_setup_services(
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert (services := hass.services.async_services_for_domain(DOMAIN))
|
||||
assert SERVICE_TEXT_COMMAND in services
|
||||
assert SERVICE_SOUND_NOTIFICATION in services
|
||||
assert SERVICE_INFO_SKILL in services
|
||||
assert "send_text_command" in services
|
||||
assert "send_sound" in services
|
||||
assert "send_info_skill" in services
|
||||
|
||||
|
||||
async def test_info_skill_service(
|
||||
@@ -58,7 +55,7 @@ async def test_info_skill_service(
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_INFO_SKILL,
|
||||
"send_info_skill",
|
||||
{
|
||||
ATTR_INFO_SKILL: "tell_joke",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
@@ -88,7 +85,7 @@ async def test_send_sound_service(
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
{
|
||||
ATTR_SOUND: "bell_02",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
@@ -118,7 +115,7 @@ async def test_send_text_service(
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_TEXT_COMMAND,
|
||||
"send_text_command",
|
||||
{
|
||||
ATTR_TEXT_COMMAND: "Play B.B.C. radio on TuneIn",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
@@ -173,7 +170,7 @@ async def test_invalid_parameters(
|
||||
with pytest.raises(ServiceValidationError) as exc_info:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
{
|
||||
ATTR_SOUND: sound,
|
||||
ATTR_DEVICE_ID: device_id,
|
||||
@@ -229,7 +226,7 @@ async def test_invalid_info_skillparameters(
|
||||
with pytest.raises(ServiceValidationError) as exc_info:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_INFO_SKILL,
|
||||
"send_info_skill",
|
||||
{
|
||||
ATTR_INFO_SKILL: info_skill,
|
||||
ATTR_DEVICE_ID: device_id,
|
||||
@@ -266,7 +263,7 @@ async def test_config_entry_not_loaded(
|
||||
with pytest.raises(ServiceValidationError) as exc_info:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
{
|
||||
ATTR_SOUND: "bell_02",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
@@ -300,7 +297,7 @@ async def test_invalid_config_entry(
|
||||
# Call Service
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
{
|
||||
ATTR_SOUND: "bell_02",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
@@ -332,7 +329,7 @@ async def test_missing_config_entry(
|
||||
with pytest.raises(ServiceValidationError) as exc_info:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_SOUND_NOTIFICATION,
|
||||
"send_sound",
|
||||
{
|
||||
ATTR_SOUND: "bell_02",
|
||||
ATTR_DEVICE_ID: device_entry.id,
|
||||
|
||||
Reference in New Issue
Block a user