Skip to content

Commit 2ba88a2

Browse files
authored
Increase test coverage to 98%: add comprehensive unit tests for client/device, retries, and export paths
## Summary - Raises repository test coverage from ~81% to 98% - Adds 45+ targeted unit tests across `fmd_api.client` and `fmd_api.device` - Focuses on previously untested error paths, retry/backoff logic, and export edge cases - No production code changes; tests only ## What changed - New tests in `tests/unit/test_coverage_improvements.py`: - Authentication flow: salt retrieval, password hashing, access token, private key decryption - Retry/backoff: 429 with Retry-After, 500/502/503/504, connection errors, jitter/no-jitter backoff - JSON parsing fallbacks: non-JSON responses, empty body, missing keys - Export ZIP: PNG/JPEG detection, default jpg fallback for unknown formats, decrypt errors - Device edge cases: photo download decode errors, internal guards - Utilities: token masking, Retry-After parsing, streaming responses - Coverage artifacts: `coverage.xml` generated for Codecov ## Why - Address Codecov alerts and improve confidence in critical paths (auth, I/O, error handling) - Reduce regressions by covering negative and edge scenarios ## Metrics - Before: ~81% total coverage (`client.py` ~77%, `device.py` ~94%) - After: 98% total coverage (`client.py` ~97%, `device.py` 100%) - Tests: 104 tests passing locally ## Compatibility - Breaking changes: None - Public API changes: None - Dependencies: No new runtime dependencies ## How to validate locally (optional) ```powershell # From repo root (Windows PowerShell) python -m pytest tests/unit --cov=fmd_api --cov-report=term-missing --cov-branch ``` ## Notes and follow-ups - Remaining uncovered lines are hard-to-trigger branches in `client.py` (e.g., specific fallback/log-only segments): `353–358`, `368`, `392–393`, `477–478`, `563`, `717–718` - Reaching 100% would likely require deeper `aiohttp` response mocking or small refactors to expose those branches for deterministic testing; can be tackled in a follow-up if desired ## Checklist - [x] All unit tests pass locally - [x] Coverage ≥ 95% (actual: 98%) - [x] No production code changes - [x] `coverage.xml` updated for CI/Codecov
2 parents dce625f + 1232106 commit 2ba88a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fmd_api"
3-
version = "2.0.1"
3+
version = "2.0.2"
44
authors = [{name = "devinslick"}]
55
description = "A Python client for the FMD (Find My Device) server API"
66
readme = "README.md"

0 commit comments

Comments
 (0)