소스 검색

Tests: stricter checking on state_class.

When class is at dp level, it corresponds to state_class (for sensors only),
which has a small set of fixed possible values.

As inexperienced users tend to confuse this with the device_class (class at
entity level), it will help to check this more thoroughly.
Jason Rumney 1 년 전
부모
커밋
20ee69d4b1
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      tests/test_device_config.py

+ 7 - 1
tests/test_device_config.py

@@ -98,7 +98,13 @@ DP_SCHEMA = vol.Schema(
         },
         vol.Optional("unit"): str,
         vol.Optional("precision"): vol.Any(int, float),
-        vol.Optional("class"): str,
+        vol.Optional("class"): vol.In(
+            [
+                "measurement",
+                "total",
+                "total_increasing",
+            ]
+        ),
         vol.Optional("optional"): True,
         vol.Optional("persist"): False,
         vol.Optional("hidden"): True,