Skip to content

Add integration tests for running against a real printer#157

Merged
agners merged 2 commits into
home-assistant-libs:mainfrom
heikkih:feat/integration-tests
May 7, 2026
Merged

Add integration tests for running against a real printer#157
agners merged 2 commits into
home-assistant-libs:mainfrom
heikkih:feat/integration-tests

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented Apr 23, 2026

Summary

  • Adds tests/test_integration.py with tests that verify actual API behavior against a real PrusaLink printer
  • Registers integration pytest mark and excludes it from default runs via addopts = "-m 'not integration'"
  • CI continues to run only unit tests; integration tests never run accidentally
  • Adds [project.optional-dependencies] test group for test deps in pyproject.toml

How to run

PRUSALINK_HOST=http://prusa.lan \
PRUSALINK_USERNAME=maker \
PRUSALINK_PASSWORD=secret \
pytest tests/test_integration.py -v -s -m integration

The -m integration flag is required to override the default -m 'not integration' from pyproject.toml.

Why

Mocked unit tests can't reveal what fields the API actually returns. This was highlighted when investigating the job.file.meta structure — we needed a real printer to confirm the actual field names. Integration tests give contributors a reproducible way to verify real behavior before typing it.

Test plan

  • Run unit tests without env vars set: pytest tests/ — integration tests should be deselected
  • Run integration tests against a real printer with env vars set — all should pass (verified against Core One firmware 6.5.3)

🤖 Generated with Claude Code

@heikkih heikkih force-pushed the feat/integration-tests branch 2 times, most recently from 3f86f2a to 64f29b2 Compare April 27, 2026 15:15
Tests are marked with pytest.mark.integration and excluded from
CI by default. Run locally with PRUSALINK_HOST, PRUSALINK_USERNAME,
and PRUSALINK_PASSWORD environment variables set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@heikkih heikkih force-pushed the feat/integration-tests branch from 64f29b2 to 1bec1ca Compare April 28, 2026 11:47
Copy link
Copy Markdown
Contributor

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, maybe we should also start to add our test dependencies to pyproject.toml (as optional dependencies like so):

test = [
  "pytest==9.0.3",
  "pytest-asyncio==1.3.0",
]

Comment thread pyproject.toml
Comment thread tests/test_integration.py Outdated
- Remove `firmware` field assertion in test_get_version (not present
  on MK3.9 firmware 6.4.0 per @agners)
- Update docstring with `-m integration` flag (required to override
  default deselection)
- Add `[project.optional-dependencies]` test group as suggested

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented May 6, 2026

Pushed 1a1e46a addressing the three points:

  1. firmware assertion dropped — the get_version() test now only asserts "api" in result, since firmware is missing on MK3.9/6.4.0
  2. Docstring updated — added -m integration to the example command so users actually get the tests selected
  3. Test extras added[project.optional-dependencies] test group with pytest, pytest-asyncio, respx

I left requirements-test.txt alone so CI keeps working — the test extras section is purely additive for now. Happy to migrate CI to pip install -e .[test] in a follow-up if you'd like.

Verified locally:

  • pytest tests/ — 15 passed, 5 deselected
  • pytest tests/test_integration.py -m integration against Core One — 5 passed

@heikkih heikkih requested a review from agners May 6, 2026 17:18
Comment thread pyproject.toml
@agners agners merged commit 5e77159 into home-assistant-libs:main May 7, 2026
2 checks passed
agners pushed a commit that referenced this pull request May 7, 2026
Move all test/lint deps from requirements-test.txt into
[project.optional-dependencies] with separate `test` and `lint`
groups, and update CI to install via `pip install -e .[test,lint]`.
The requirements-test.txt file is removed.

Per @agners' follow-up note on #157.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@heikkih heikkih deleted the feat/integration-tests branch May 13, 2026 10:48
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.

2 participants