Skip to content

test: add unit tests for sensor.py#266

Merged
ardevd merged 2 commits into
mainfrom
sensor-tests
Mar 10, 2026
Merged

test: add unit tests for sensor.py#266
ardevd merged 2 commits into
mainfrom
sensor-tests

Conversation

@ardevd

@ardevd ardevd commented Mar 10, 2026

Copy link
Copy Markdown
Owner

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

Added comprehensive test cases for `DimoSensorEntity` and `DimoVehicleSensorEntity`
including value formatting, unit mapping, and error handling for missing values.
@ardevd ardevd self-assigned this Mar 10, 2026
@ardevd ardevd added the enhancement New feature or request label Mar 10, 2026
Copilot AI review requested due to automatic review settings March 10, 2026 20:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_value behavior for both non-vehicle and vehicle sensors, including missing-data cases.
  • Adds tests for native_unit_of_measurement behavior for both sensor types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_sensor.py
Comment on lines +7 to +15
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

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_sensor.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@redbird-sonarqube

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@ardevd ardevd merged commit db3f0bf into main Mar 10, 2026
6 checks passed
@ardevd ardevd deleted the sensor-tests branch March 10, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants