mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Directly check string representation of sensor states in APCUPSD tests (#93783)
* Directly check the string representation of sensor states * Fix expected state value for sensor.ups_nominal_output_power
This commit is contained in:
parent
fe472e6c5b
commit
0653aed49f
@ -1,5 +1,4 @@
|
||||
"""Test sensors of APCUPSd integration."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
@ -35,7 +34,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
||||
# Test two representative voltage sensors.
|
||||
state = hass.states.get("sensor.ups_input_voltage")
|
||||
assert state
|
||||
assert pytest.approx(float(state.state)) == 124.0
|
||||
assert state.state == "124.0"
|
||||
assert (
|
||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricPotential.VOLT
|
||||
)
|
||||
@ -47,7 +46,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
||||
|
||||
state = hass.states.get("sensor.ups_battery_voltage")
|
||||
assert state
|
||||
assert pytest.approx(float(state.state)) == 13.7
|
||||
assert state.state == "13.7"
|
||||
assert (
|
||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfElectricPotential.VOLT
|
||||
)
|
||||
@ -60,7 +59,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
||||
# Test a representative percentage sensor.
|
||||
state = hass.states.get("sensor.ups_load")
|
||||
assert state
|
||||
assert pytest.approx(float(state.state)) == 14.0
|
||||
assert state.state == "14.0"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||
entry = registry.async_get("sensor.ups_load")
|
||||
@ -70,7 +69,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
||||
# Test a representative wattage sensor.
|
||||
state = hass.states.get("sensor.ups_nominal_output_power")
|
||||
assert state
|
||||
assert pytest.approx(float(state.state)) == 330.0
|
||||
assert state.state == "330"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.WATT
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.POWER
|
||||
entry = registry.async_get("sensor.ups_nominal_output_power")
|
||||
|
Loading…
x
Reference in New Issue
Block a user