M5-T11: add HA discovery and state publishing wired to polling
This commit is contained in:
@@ -108,11 +108,17 @@ def test_exposable_entity_fields():
|
||||
|
||||
|
||||
def test_exposable_entity_with_value_getter():
|
||||
"""ExposableEntity.value_getter stores and calls the provided callable."""
|
||||
"""ExposableEntity.value_getter stores and calls the provided callable.
|
||||
|
||||
value_getter now accepts a Session argument (updated in T11-rework-1).
|
||||
"""
|
||||
from app.integrations.expose import DeviceInfo, ExposableEntity
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
device = DeviceInfo(identifiers=("modbus", "dev1"), name="D1")
|
||||
getter = lambda: 230.5 # noqa: E731
|
||||
# The value_getter receives a Session; use a lambda that ignores it.
|
||||
getter = lambda _sess: 230.5 # noqa: E731
|
||||
entity = ExposableEntity(
|
||||
key="modbus.dev1.voltage",
|
||||
component="sensor",
|
||||
@@ -123,7 +129,9 @@ def test_exposable_entity_with_value_getter():
|
||||
value_getter=getter,
|
||||
)
|
||||
assert entity.value_getter is not None
|
||||
assert entity.value_getter() == 230.5
|
||||
eng = create_engine("sqlite:///:memory:")
|
||||
with Session(eng) as session:
|
||||
assert entity.value_getter(session) == 230.5
|
||||
|
||||
|
||||
def test_entity_key_stability_uses_uuid_not_id():
|
||||
|
||||
Reference in New Issue
Block a user