Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/sensor_state_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
from .base import BaseDeviceClass
from .binary_sensor.device_class import BinarySensorDeviceClass
from .data import SensorData, SensorDeviceInfo, SensorUpdate
from .description import BinarySensorDescription, SensorDescription
from .description import (
BaseBinarySensorDescription,
BaseDescription,
BaseSensorDescription,
BinarySensorDescription,
SensorDescription,
)
from .device import DeviceKey
from .device_class import DeviceClass
from .library import SensorLibrary
Expand All @@ -12,7 +18,10 @@
from .value import BaseValue, BinarySensorValue, Event, SensorValue

__all__ = [
"BaseBinarySensorDescription",
"BaseDescription",
"BaseDeviceClass",
"BaseSensorDescription",
"BaseValue",
"BinarySensorValue",
"BinarySensorDescription",
Expand Down
28 changes: 28 additions & 0 deletions tests/test_public_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Public API surface contract."""

import sensor_state_data
from sensor_state_data import (
BaseBinarySensorDescription,
BaseDescription,
BaseSensorDescription,
SensorLibrary,
)


def test_base_description_classes_importable_from_root():
"""Base description classes are part of the public API."""
assert issubclass(BaseSensorDescription, BaseDescription)
assert issubclass(BaseBinarySensorDescription, BaseDescription)


def test_sensor_library_entries_are_base_sensor_descriptions():
"""SensorLibrary exposes BaseSensorDescription instances, so the class
must be importable from the package root to annotate/check them."""
entry = SensorLibrary.BATTERY__PERCENTAGE
assert isinstance(entry, BaseSensorDescription)


def test_all_names_are_importable():
"""Every name in __all__ resolves to a real attribute."""
for name in sensor_state_data.__all__:
assert hasattr(sensor_state_data, name), name
Loading