Skip to content

test: cover pounds/catty unit conversion in Mi Scale parsers - #352

Open
bluetoothbot wants to merge 1 commit into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/test-scale-unit-conversions
Open

bluetoothbot wants to merge 1 commit into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/test-scale-unit-conversions

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What: Add test coverage for the pounds and catty weight-unit conversion branches in the legacy Mi Scale parsers.

Why: _parse_scale_v1 (XMTZC01HM/04HM) and _parse_scale_v2 (XMTZC02HM/05HM/NUN4049CN) convert the raw mass field to kilograms based on a unit flag in the control byte(s). Only the kilograms path had tests — the lbs → kg (×0.0045359237) and catty → kg (×0.005) branches were entirely uncovered, so a regression in either factor would silently ship wrong weights to users in lb/catty locales.

How: Four tests (V1/V2 × pounds/catty), each a synthesized advert with the appropriate unit bit set. Pounds values are asserted as the exact arithmetic expression (field * 0.0045359237) for bit-exact float equality; catty fields were chosen to land on clean values (87.0 kg). Parser used as the oracle.

Testing: poetry run pytest tests/ → 136 passed (was 132). black/isort/flake8 clean.


Quality Report

Changes: 1 file changed, 310 insertions(+)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan

The _parse_scale_v1 and _parse_scale_v2 pound and catty conversion
branches had no coverage — only the kilograms path was exercised. A
regression in either conversion factor would silently give wrong
weights to users in lb/catty locales. Adds four tests (V1/V2 x
pounds/catty) with the parser as the oracle.
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.98%. Comparing base (902d017) to head (7327d5f).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   59.41%   59.98%   +0.56%     
==========================================
  Files           7        7              
  Lines        1412     1412              
  Branches      278      278              
==========================================
+ Hits          839      847       +8     
+ Misses        444      438       -6     
+ Partials      129      127       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ernst79
Ernst79 marked this pull request as ready for review August 10, 2026 18:24

This branch has not been deployed

No deployments
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.

1 participant