mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Refactor SmartThings sensor platform (#138313)
This commit is contained in:
parent
8e7f35aa7d
commit
3489b20e86
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,9 @@ The only mocking required is of the underlying SmartThings API object so
|
||||
real HTTP calls are not initiated during testing.
|
||||
"""
|
||||
|
||||
from pysmartthings import ATTRIBUTES, CAPABILITIES, Attribute, Capability
|
||||
from pysmartthings import Attribute, Capability
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
DEVICE_CLASSES,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
STATE_CLASSES,
|
||||
)
|
||||
from homeassistant.components.smartthings import sensor
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.smartthings.const import DOMAIN, SIGNAL_SMARTTHINGS_UPDATE
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
@ -29,20 +24,6 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from .conftest import setup_platform
|
||||
|
||||
|
||||
async def test_mapping_integrity() -> None:
|
||||
"""Test ensures the map dicts have proper integrity."""
|
||||
for capability, maps in sensor.CAPABILITY_TO_SENSORS.items():
|
||||
assert capability in CAPABILITIES, capability
|
||||
for sensor_map in maps:
|
||||
assert sensor_map.attribute in ATTRIBUTES, sensor_map.attribute
|
||||
if sensor_map.device_class:
|
||||
assert sensor_map.device_class in DEVICE_CLASSES, (
|
||||
sensor_map.device_class
|
||||
)
|
||||
if sensor_map.state_class:
|
||||
assert sensor_map.state_class in STATE_CLASSES, sensor_map.state_class
|
||||
|
||||
|
||||
async def test_entity_state(hass: HomeAssistant, device_factory) -> None:
|
||||
"""Tests the state attributes properly match the sensor types."""
|
||||
device = device_factory("Sensor 1", [Capability.battery], {Attribute.battery: 100})
|
||||
@ -75,7 +56,9 @@ async def test_entity_three_axis_invalid_state(
|
||||
) -> None:
|
||||
"""Tests the state attributes properly match the three axis types."""
|
||||
device = device_factory(
|
||||
"Three Axis", [Capability.three_axis], {Attribute.three_axis: []}
|
||||
"Three Axis",
|
||||
[Capability.three_axis],
|
||||
{Attribute.three_axis: [None, None, None]},
|
||||
)
|
||||
await setup_platform(hass, SENSOR_DOMAIN, devices=[device])
|
||||
state = hass.states.get("sensor.three_axis_x_coordinate")
|
||||
|
Loading…
x
Reference in New Issue
Block a user