Continues narrowing SamsungEntityDescription accesses to the correct subclass and asserting Optional write_fn/match_fn/exists_fn fields are set before calling them, per the pattern established in the previous commit.
21 lines
629 B
Python
21 lines
629 B
Python
from custom_components.localthings.registry.capability import Capability
|
|
from custom_components.localthings.registry.entities import BinarySensorDesc
|
|
|
|
|
|
def test_capability_defaults():
|
|
c = Capability(
|
|
href="/kidslock/vs/0",
|
|
entities=(BinarySensorDesc(key="child_lock", field="x.com.samsung.da.kidsLock"),),
|
|
)
|
|
assert c.poll_tier == "cold"
|
|
assert len(c.entities) == 1
|
|
|
|
|
|
def test_capability_is_frozen():
|
|
c = Capability(href="/kidslock/vs/0", entities=())
|
|
try:
|
|
setattr(c, "href", "/other/vs/0")
|
|
except Exception:
|
|
return
|
|
raise AssertionError("expected frozen dataclass")
|