Skip to content

Add tests for uncovered exception and edge-case branches - #69

Merged
kylegordon merged 2 commits into
masterfrom
improve-test-coverage
Jun 30, 2026
Merged

Add tests for uncovered exception and edge-case branches#69
kylegordon merged 2 commits into
masterfrom
improve-test-coverage

Conversation

@kylegordon

Copy link
Copy Markdown
Owner

Summary

  • _get_position_time fallback paths (test_sensor.py): covers the two branches where parse_datetime returns None or raises ValueError/TypeError — both fall back to returning device.lastPos.timeMeasure directly
  • _get_mode / _get_mode_attrs with None mode (test_sensor.py): verifies the sensor returns None and {} when device.mode is None
  • PetTracerDeviceTracker.available returning False (test_device_tracker.py): verifies the tracker reports unavailable when its device is no longer present in coordinator data
  • Reauth unknown exception (test_config_flow.py): covers async_step_reauth_confirm's except Exception branch (the equivalent user-step path was already tested)
  • last_contact attribute (test_device_tracker.py): adds assertion to existing attributes test to verify the key is present

Test plan

  • CI pytest job passes
  • Coverage remains ≥ 80%

🤖 Generated with Claude Code

kylegordon and others added 2 commits June 30, 2026 10:02
Cover five previously untested paths:
- `_get_position_time`: parse_datetime returns None (fallback to raw value)
- `_get_position_time`: parse_datetime raises ValueError (fallback to raw value)
- `_get_mode` / `_get_mode_attrs`: device.mode is None → returns None / {}
- `PetTracerDeviceTracker.available`: returns False when device absent from coordinator
- `async_step_reauth_confirm`: unknown exception → errors["base"] = "unknown"
Also assert `last_contact` key in device tracker attributes test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The test suite now covers all major branches including exception
fallbacks and edge cases, making 90% a meaningful and achievable bar.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kylegordon
kylegordon merged commit 1380e6c into master Jun 30, 2026
5 checks passed
@kylegordon
kylegordon deleted the improve-test-coverage branch June 30, 2026 09:25
@github-actions github-actions Bot mentioned this pull request Jun 30, 2026
kylegordon added a commit that referenced this pull request Aug 16, 2026
## What's Changed
* Add tests for uncovered exception and edge-case branches by
@kylegordon in #69
* chore(deps): update pytest-homeassistant-custom-component requirement
from >=0.13.342 to >=0.13.345 by @dependabot[bot] in
#71
* chore(deps): update pytest-homeassistant-custom-component requirement
from >=0.13.345 to >=0.13.346 by @dependabot[bot] in
#72
* chore(deps): update pytest-homeassistant-custom-component requirement
from >=0.13.346 to >=0.13.348 by @dependabot[bot] in
#74
* chore(deps): update pytest-homeassistant-custom-component requirement
from >=0.13.348 to >=0.13.350 by @dependabot[bot] in
#75
* chore(deps): bump actions/setup-python from 6 to 7 by @dependabot[bot]
in #73
* chore(deps): update pytest-homeassistant-custom-component requirement
from >=0.13.350 to >=0.13.354 by @dependabot[bot] in
#76
* gh aw daily-repo by @kylegordon in
#77
* Add agentic workflow grumpy-reviewer by @kylegordon in
#78
* Make entity naming and entity_id independent of pet name by
@kylegordon in #80
* Pin Copilot CLI version in grumpy-reviewer to avoid toolcache ENOENT
by @kylegordon in #84


**Full Changelog**:
v1.0.8...v1.0.9

Co-authored-by: kylegordon <231528+kylegordon@users.noreply.github.com>
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