test: add unit tests for sensor.py#266
Conversation
Added comprehensive test cases for `DimoSensorEntity` and `DimoVehicleSensorEntity` including value formatting, unit mapping, and error handling for missing values.
There was a problem hiding this comment.
Pull request overview
Adds a new unit test module to validate the behavior of DimoSensorEntity and DimoVehicleSensorEntity in the DIMO Home Assistant integration.
Changes:
- Adds tests for
native_valuebehavior for both non-vehicle and vehicle sensors, including missing-data cases. - Adds tests for
native_unit_of_measurementbehavior for both sensor types.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class MockSensorDef: | ||
| def __init__(self, unit_of_measure=None, platform=Platform.SENSOR, name="mock_name", device_class=None, icon=None, state_class=None): | ||
| self.unit_of_measure = unit_of_measure | ||
| self.platform = platform | ||
| self.name = name | ||
| self.device_class = device_class | ||
| self.icon = icon | ||
| self.state_class = state_class | ||
|
|
There was a problem hiding this comment.
This test module doesn’t follow the spacing conventions used in other tests (two blank lines between top-level defs/classes; e.g. tests/test_binary_sensor.py:10-24, tests/test_auth.py:12-32). Aligning this file (and wrapping the long MockSensorDef.__init__ signature) improves readability and avoids formatter churn.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|





Added comprehensive test cases for
DimoSensorEntityandDimoVehicleSensorEntityincluding value formatting, unit mapping, and error handling for missing values.