Add test infrastructure: pytest, pytest-asyncio, respx#154
Merged
agners merged 4 commits intoApr 27, 2026
Conversation
Adds a proper test suite to replace the lint-only CI. The tests cover: - ApiClient error handling (InvalidAuth on 401, Conflict on 409, NotFound on 404) - DigestAuthWorkaround behaviour (omits algorithm without qop, delegates to parent when qop is present) - Happy-path coverage for all PrusaLink public methods Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 2026
Contributor
Author
|
Quick note:
|
agners
requested changes
Apr 24, 2026
Contributor
agners
left a comment
There was a problem hiding this comment.
Thank you for working on this!
- Rename conftest fixture to `pl` and use it in both test files instead of duplicating inline client setup - Remove tests/__init__.py (not needed for pytest discovery) - Replace hacky __bases__ monkey-patch with patch.object(DigestAuth, ...) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agners
requested changes
Apr 27, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agners
approved these changes
Apr 27, 2026
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
This PR establishes a proper test suite for pyprusalink, replacing the current lint-only CI with real unit tests. It is the first in a planned series of improvements to both this library and the Home Assistant
prusalinkintegration.What's included
requirements-test.txt: addspytest,pytest-asyncio, andrespxpyproject.toml: adds[tool.pytest.ini_options]withasyncio_mode = "auto"and corrects the Python classifier versions (3.9/3.10 → 3.11/3.12 to match CI).github/workflows/test.yml: extends linting to thetests/directory and adds apytest tests/steptests/conftest.py: shared fixturestests/test_client.py: coversApiClienterror handling (InvalidAuthon 401,Conflicton 409,NotFoundon 404) andDigestAuthWorkaroundbehaviour (omitsalgorithmwithoutqop, delegates to parent whenqopis present)tests/test_prusalink.py: happy-path coverage for all existingPrusaLinkpublic methods (get_version,get_info,get_status,get_job,get_legacy_printer,cancel_job,pause_job,resume_job,get_file), including the 204 no-job caseAll 15 tests pass in ~0.1s.
Planned follow-up PRs
Once this lands, the next PRs in the series will:
DigestAuthWorkaround— both upstream issues are now resolved (httpx 0.27.0, Feb 2024; Prusa firmware 5.2.0, Feb 2024). The workaround can be dropped once firmware 5.2.0+ is the minimum supported version.continue_job()— the missing complement topause_job/resume_jobfor timelapse workflows.metafield inJobFilePrintwith a properPrintFileMetadataTypedDict, exposing filament type, material name, estimated usage, layer height, etc.transfer,storage, andcamerasub-objects already returned byGET /api/v1/statusbut currently ignored.get_storage(),get_transfer(),get_camera_snapshot(),get_update_info().The goal is to give the Home Assistant integration richer, well-typed data to work with — enabling sensors for filament type, storage free space, upload progress, live camera snapshots, and firmware update availability.
Test plan
pytest tests/ -v— 15 passedflake8 pyprusalink tests— no errorsblack --check pyprusalink tests— no reformats neededisort --check pyprusalink tests— no changes needed🤖 Generated with Claude Code