Add pytest test suite with 96% coverage and GitHub Actions CI - #4
Open
geofffranks wants to merge 4 commits into
Open
Add pytest test suite with 96% coverage and GitHub Actions CI#4geofffranks wants to merge 4 commits into
geofffranks wants to merge 4 commits into
Conversation
Collaborator
Author
|
Sorry for the terseness in the PR notes, and plethora of commits, Claude got a bit much there. Essentially - Adds a ton of test coverage to bring the overall coverage up to 96%. This also adds a github action for auto-running the tests for PRs and for commits to the main branch. As such didn't want to push/merge directly without checking with you first on this one @LF2b2w. |
Collaborator
Author
|
Ah, also it looks like branch protection + reviewer requirements effectively prevent me from merging/pushing on my own anyway. If that was intended and i misinterpreted, no worried, just mentioning in case. |
geofffranks
force-pushed
the
test-coverage-90
branch
2 times, most recently
from
July 8, 2026 15:16
090375c to
2570e30
Compare
Collaborator
Author
|
@LF2b2w bumping this PR as well |
Squash of the geofffranks/utec-py fork divergence: simplified Auth, device class restructuring, corrected switch/light/lock command payloads and state reading, HA lock state wording, plus a full unit-test suite (transport, Lock, Light, Switch, BaseDevice) and CI running pytest with coverage on push to main and all PRs. Tracked by tk up-jgns. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
geofffranks
force-pushed
the
test-coverage-90
branch
from
August 20, 2026 23:02
2570e30 to
9442258
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/test_utec.py(wrong imports, references to non-existent methods like_api_call/_discoverandUtecOAuth2which lives in the HA integration, not this library) with a working pytest suite across 10 new test files covering API transport, device classes, auth, exceptions, and constants.pytest-asyncio+coverageconfiguration inpyproject.tomlwith afail_under = 90gate, plus a pinnedrequirements-test.txtand a rewrittentests/conftest.pyproviding shared fixtures (mock_api,discovery_dict,state_payload,_FakeAuth)..github/workflows/test.yml) that runs the suite with coverage on push tomainand on all pull requests, across a Python 3.11 / 3.12 matrix.api.py/auth.py/const.py/exceptions.py100%,light.py99%,lock.py98%,device.py96%,switch.py94%,device_const.py87%.Test Plan
pip install -e . -r requirements-test.txtpytest tests/— expect 126 passed, 0 failedpytest tests/ --cov=utec_py --cov-report=term-missing— expect ≥90% overall, all required modules ≥90%tests/test_api.pyfor HTTP transport viaaioresponses,tests/test_lock.pyfor device state assertions)Notes for Maintainers
src/changes. Several tests adapt to observed source behavior rather than "correcting" it — for exampleLockState/DoorStateenum values are title case,BaseDevice.updatewraps errors asDeviceError,battery_levelmaps integer keys{1→10, 2→30, 3→50, 4→70, 5→100}, andDeviceErrorinherits directly fromExceptionrather thanUHomeError. These are documented inline where relevant.docs/superpowers/plans/contains the implementation plan and source audit used to produce this branch. They are process artifacts — feel free to squash them out of the merge if you prefer a cleaner history.tests/test_api.pydefines its own_FakeAuthsubclass that duplicates the one intests/conftest.py. Both work; consolidation can be done in a follow-up if desired.