Przeglądaj źródła

Tests: update not to use deprecated STATE_CLASS_... constants.

These will be removed in HA 2025.1, which breaks the tests.
Jason Rumney 1 rok temu
rodzic
commit
fb274cbaa9

+ 4 - 4
tests/devices/test_energy_monitoring_powerstrip.py

@@ -1,6 +1,6 @@
 """Tests for the energy monitoring powerstrip."""
 
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
 from homeassistant.components.switch import SwitchDeviceClass
 from homeassistant.const import (
     UnitOfElectricCurrent,
@@ -69,14 +69,14 @@ class TestEnergyMonitoringPowerstrip(
                     "dps": CURRENT_DP,
                     "device_class": SensorDeviceClass.CURRENT,
                     "unit": UnitOfElectricCurrent.MILLIAMPERE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
                 {
                     "name": "sensor_power",
                     "dps": POWER_DP,
                     "device_class": SensorDeviceClass.POWER,
                     "unit": UnitOfPower.WATT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (1234, 123.4),
                 },
                 {
@@ -84,7 +84,7 @@ class TestEnergyMonitoringPowerstrip(
                     "dps": VOLTAGE_DP,
                     "device_class": SensorDeviceClass.VOLTAGE,
                     "unit": UnitOfElectricPotential.VOLT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (2345, 234.5),
                 },
             ]

+ 2 - 2
tests/devices/test_himox_h05_purifier.py

@@ -1,5 +1,5 @@
 from homeassistant.components.fan import FanEntityFeature
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SnesorStateClass
 from homeassistant.const import PERCENTAGE, UnitOfTemperature
 
 from ..const import HIMOX_H05_PURIFIER_PAYLOAD
@@ -58,7 +58,7 @@ class TestHimoxH05Purifier(
                     "name": "sensor_temperature",
                     "unit": UnitOfTemperature.CELSIUS,
                     "device_class": SensorDeviceClass.TEMPERATURE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
                 {
                     "dps": FILTER_DPS,

+ 3 - 3
tests/devices/test_jiahong_et72w_thermostat.py

@@ -1,6 +1,6 @@
 from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
 from homeassistant.components.number.const import NumberDeviceClass
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
 from homeassistant.const import UnitOfTemperature, UnitOfTime
 
 from ..const import JIAHONG_ET72W_PAYLOAD
@@ -102,7 +102,7 @@ class TestJiahongEt72wThermostat(
                     "dps": CURRENTTEMP_DPS,
                     "name": "sensor_room_temperature",
                     "device_class": SensorDeviceClass.TEMPERATURE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "unit": UnitOfTemperature.CELSIUS,
                     "testdata": (195, 19.5),
                 },
@@ -110,7 +110,7 @@ class TestJiahongEt72wThermostat(
                     "dps": FLOORTEMP_DPS,
                     "name": "sensor_floor_temperature",
                     "device_class": SensorDeviceClass.TEMPERATURE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "unit": UnitOfTemperature.CELSIUS,
                     "testdata": (214, 21.4),
                 },

+ 2 - 2
tests/devices/test_kyvol_e30_vacuum.py

@@ -1,5 +1,5 @@
 from homeassistant.components.button import ButtonDeviceClass
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
 from homeassistant.components.vacuum import (
     STATE_CLEANING,
     STATE_ERROR,
@@ -102,7 +102,7 @@ class TestKyvolE30Vacuum(MultiButtonTests, MultiSensorTests, TuyaDeviceTestCase)
                     "name": "sensor_battery",
                     "unit": PERCENTAGE,
                     "device_class": SensorDeviceClass.BATTERY,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
             ],
         )

+ 2 - 2
tests/devices/test_lefant_m213_vacuum.py

@@ -1,4 +1,4 @@
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
 from homeassistant.components.vacuum import (
     STATE_CLEANING,
     STATE_ERROR,
@@ -57,7 +57,7 @@ class TestLefantM213Vacuum(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_battery",
                     "unit": PERCENTAGE,
                     "device_class": SensorDeviceClass.BATTERY,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
             ],
         )

+ 2 - 2
tests/devices/test_parkside_plgs2012a1_smart_charger.py

@@ -2,7 +2,7 @@
 
 from homeassistant.components.binary_sensor import BinarySensorDeviceClass
 from homeassistant.components.number.const import NumberDeviceClass
-from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
+from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
 from homeassistant.const import (
     PERCENTAGE,
     UnitOfElectricCurrent,
@@ -119,7 +119,7 @@ class TestParksidePLGS2012A1Charger(
                     "dps": TEMPERATURE_DPS,
                     "unit": UnitOfTemperature.CELSIUS,
                     "device_class": SensorDeviceClass.TEMPERATURE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
                 {
                     "name": "sensor_max_current",

+ 18 - 19
tests/devices/test_pc321ty_energy_meter.py

@@ -1,9 +1,8 @@
 """Tests for the PC321-TY Power Clamp Energy meter"""
 
 from homeassistant.components.sensor import (
-    STATE_CLASS_MEASUREMENT,
-    STATE_CLASS_TOTAL_INCREASING,
     SensorDeviceClass,
+    SensorStateClass,
 )
 from homeassistant.const import (
     UnitOfElectricCurrent,
@@ -55,7 +54,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_energy",
                     "unit": UnitOfEnergy.KILO_WATT_HOUR,
                     "device_class": SensorDeviceClass.ENERGY,
-                    "state_class": STATE_CLASS_TOTAL_INCREASING,
+                    "state_class": SensorStateClass.TOTAL_INCREASING,
                     "testdata": (12345, 123.45),
                 },
                 {
@@ -63,7 +62,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_voltage_a",
                     "unit": UnitOfElectricPotential.VOLT,
                     "device_class": SensorDeviceClass.VOLTAGE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (2348, 234.8),
                 },
                 {
@@ -71,21 +70,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_current_a",
                     "unit": UnitOfElectricCurrent.AMPERE,
                     "device_class": SensorDeviceClass.CURRENT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (4567, 4.567),
                 },
                 {
                     "dps": POWER1_DP,
                     "name": "sensor_power_a",
                     "unit": UnitOfPower.WATT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "device_class": SensorDeviceClass.POWER,
                 },
                 {
                     "dps": PFACTOR1_DP,
                     "name": "sensor_power_factor_a",
                     "device_class": SensorDeviceClass.POWER_FACTOR,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (5000, 50.00),
                 },
                 {
@@ -99,7 +98,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_voltage_b",
                     "unit": UnitOfElectricPotential.VOLT,
                     "device_class": SensorDeviceClass.VOLTAGE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (2348, 234.8),
                 },
                 {
@@ -107,7 +106,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_current_b",
                     "unit": UnitOfElectricCurrent.AMPERE,
                     "device_class": SensorDeviceClass.CURRENT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (4567, 4.567),
                 },
                 {
@@ -115,13 +114,13 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_power_b",
                     "unit": UnitOfPower.WATT,
                     "device_class": SensorDeviceClass.POWER,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                 },
                 {
                     "dps": PFACTOR2_DP,
                     "name": "sensor_power_factor_b",
                     "device_class": SensorDeviceClass.POWER_FACTOR,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (5000, 50.00),
                 },
                 {
@@ -135,7 +134,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_voltage_c",
                     "unit": UnitOfElectricPotential.VOLT,
                     "device_class": SensorDeviceClass.VOLTAGE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (2348, 234.8),
                 },
                 {
@@ -143,21 +142,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_current_c",
                     "unit": UnitOfElectricCurrent.AMPERE,
                     "device_class": SensorDeviceClass.CURRENT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (4567, 4.567),
                 },
                 {
                     "dps": POWER3_DP,
                     "name": "sensor_power_c",
                     "unit": UnitOfPower.WATT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "device_class": SensorDeviceClass.POWER,
                 },
                 {
                     "dps": PFACTOR3_DP,
                     "name": "sensor_power_factor_c",
                     "device_class": SensorDeviceClass.POWER_FACTOR,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (5000, 50.00),
                 },
                 {
@@ -171,21 +170,21 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_total_current",
                     "unit": UnitOfElectricCurrent.AMPERE,
                     "device_class": SensorDeviceClass.CURRENT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (12345, 12.345),
                 },
                 {
                     "dps": TOTALPOWER_DP,
                     "name": "sensor_total_active_power",
                     "unit": UnitOfPower.WATT,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "device_class": SensorDeviceClass.POWER,
                 },
                 {
                     "dps": FREQUENCY_DP,
                     "name": "sensor_frequency",
                     "unit": UnitOfFrequency.HERTZ,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "device_class": SensorDeviceClass.FREQUENCY,
                 },
                 {
@@ -193,7 +192,7 @@ class TestPC321TYPowerClamp(MultiSensorTests, TuyaDeviceTestCase):
                     "name": "sensor_temperature",
                     "unit": UnitOfTemperature.CELSIUS,
                     "device_class": SensorDeviceClass.TEMPERATURE,
-                    "state_class": STATE_CLASS_MEASUREMENT,
+                    "state_class": SensorStateClass.MEASUREMENT,
                     "testdata": (234, 23.4),
                 },
             ]