Add API scope checks to Teslemetry (#113640)
This commit is contained in:
parent
a33aacfcaa
commit
f249a9ba4b
7 changed files with 99 additions and 8 deletions
|
@ -22,11 +22,11 @@ from homeassistant.components.climate import (
|
|||
from homeassistant.components.teslemetry.coordinator import SYNC_INTERVAL
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import assert_entities, setup_platform
|
||||
from .const import WAKE_UP_ASLEEP, WAKE_UP_ONLINE
|
||||
from .const import METADATA_NOSCOPE, WAKE_UP_ASLEEP, WAKE_UP_ONLINE
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
@ -176,3 +176,30 @@ async def test_asleep_or_offline(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
mock_wake_up.assert_called_once()
|
||||
|
||||
|
||||
async def test_climate_noscope(
|
||||
hass: HomeAssistant,
|
||||
mock_metadata,
|
||||
) -> None:
|
||||
"""Tests that the climate entity is correct."""
|
||||
mock_metadata.return_value = METADATA_NOSCOPE
|
||||
|
||||
await setup_platform(hass, [Platform.CLIMATE])
|
||||
entity_id = "climate.test_climate"
|
||||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: [entity_id], ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: [entity_id], ATTR_TEMPERATURE: 20},
|
||||
blocking=True,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue