Ver código fonte

tests(device_config): add test for incompatible mappings

Flush out issues with wrong type used for enum mappings, etc
Jason Rumney 10 horas atrás
pai
commit
6441993a26
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      tests/test_device_config.py

+ 6 - 0
tests/test_device_config.py

@@ -489,6 +489,12 @@ def check_entity(entity, cfg, mocker):
                 pytest.fail(
                 pytest.fail(
                     f"\n::error file={fname},line={line}::invert is only valid for numeric values in {cfg}; entity {e}, dp {dp.name}"
                     f"\n::error file={fname},line={line}::invert is only valid for numeric values in {cfg}; entity {e}, dp {dp.name}"
                 )
                 )
+            dpv = m.get("dps_val")
+            if dpv is not None:
+                assert _typematch(dpv, dp_type), (
+                    f"\n::error file={fname},line={line}::dps_val {dpv} is not compatible with "
+                    f"type {dp_type} in {cfg}; entity {e}, dp {dp.name}"
+                )
             for c in conditions:
             for c in conditions:
                 if c.get("value_redirect"):
                 if c.get("value_redirect"):
                     redirects.add(c.get("value_redirect"))
                     redirects.add(c.get("value_redirect"))