diff --git a/src/sensor_state_data/__init__.py b/src/sensor_state_data/__init__.py index e1ff494..f83afdd 100644 --- a/src/sensor_state_data/__init__.py +++ b/src/sensor_state_data/__init__.py @@ -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 @@ -12,7 +18,10 @@ from .value import BaseValue, BinarySensorValue, Event, SensorValue __all__ = [ + "BaseBinarySensorDescription", + "BaseDescription", "BaseDeviceClass", + "BaseSensorDescription", "BaseValue", "BinarySensorValue", "BinarySensorDescription", diff --git a/tests/test_public_api.py b/tests/test_public_api.py new file mode 100644 index 0000000..338cbb8 --- /dev/null +++ b/tests/test_public_api.py @@ -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