Skip to content

test(energy): assert parsed properties on negative and empty auto-update intervals - #107

Merged
GreenGrassBlueOcean merged 1 commit into
masterfrom
test/who18-auto-update-interval-assertions
Oct 11, 2026
Merged

GreenGrassBlueOcean merged 1 commit into
masterfrom
test/who18-auto-update-interval-assertions

Conversation

@GreenGrassBlueOcean

Copy link
Copy Markdown
Contributor

WHO 18 Auto-Update Telemetry Clamping Assertions

Follow-up to #102 addressing the review observation by @fedem95 on PR #102 (review 5482727424):

"Non-blocking note: test_negative_interval_clamped_to_stopped currently checks a local clamp after mutating the event, rather than exercising the code path that sets _update_interval. Consider adjusting it to assert the parsed event properties and log after passing through that path."


What changes?

  1. Exercise OWNEnergyEvent.__init__ Clamping Path:

    • In test_negative_interval_clamped_to_stopped, intercept OWNEvent.__init__ using monkeypatch so that self._dimension_value = ["-5"] before OWNEnergyEvent's dimension-1200 parsing branch runs.
    • Assert all parsed properties directly on the instance:
      • update_interval == 0
      • stream_duration == 0
      • is_streaming_active is False
      • human_readable_log == "Sensor 1 automatic updates stopped."
  2. Add test_empty_interval_clamped_to_stopped:

    • Tests un-mocked wire parsing for empty parameter frames (*#18*51*1200#1*##).
    • Verifies _integer_value([""], 0) fallback behavior and asserts the same stopped state properties.

Verification

  • Test suite: 1,316 passed (pytest -p no:homeassistant).
  • Coverage: 100.0% coverage maintained across all 24 modules (4,140 / 4,140 statements).
  • Standards & Linters: verify_library_standards.py and ruff check pass with 0 errors.

…ate intervals

Follow-up to PR #102 review observation from @fedem95:
- Exercise OWNEnergyEvent.__init__ parsing path with corrupted negative interval via monkeypatch
- Assert update_interval, stream_duration, is_streaming_active, and human_readable_log
- Add test_empty_interval_clamped_to_stopped to verify on-wire empty parameter fallback
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fedem95 fedem95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. This follow-up exercises the parsed event state for both negative and empty auto-update intervals, addressing the observation on #102. All checks pass.

@GreenGrassBlueOcean
GreenGrassBlueOcean merged commit a223230 into master Oct 11, 2026
16 checks passed
@GreenGrassBlueOcean
GreenGrassBlueOcean deleted the test/who18-auto-update-interval-assertions branch October 11, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants