Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ dependencies = [
"httpx",
]

[project.optional-dependencies]
test = [
"pytest>=8.0",
"pytest-asyncio>=0.24",
"respx>=0.22",
Comment thread
heikkih marked this conversation as resolved.
]

[tool.setuptools]
platforms = ["any"]
zip-safe = true
Expand Down Expand Up @@ -70,3 +77,5 @@ combine_as_imports = true

[tool.pytest.ini_options]
asyncio_mode = "auto"
markers = ["integration: requires a real PrusaLink printer (skipped in CI)"]
addopts = "-m 'not integration'"
Comment thread
heikkih marked this conversation as resolved.
62 changes: 62 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Integration tests against a real PrusaLink printer.

Run with:
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. All tests are skipped
when PRUSALINK_HOST is not set.
"""

import os

import httpx
from pyprusalink import PrusaLink
import pytest

pytestmark = pytest.mark.integration


@pytest.fixture
async def printer():
host = os.environ.get("PRUSALINK_HOST")
if not host:
pytest.skip("PRUSALINK_HOST not set")
username = os.environ.get("PRUSALINK_USERNAME", "maker")
password = os.environ.get("PRUSALINK_PASSWORD", "")
async with httpx.AsyncClient() as client:
yield PrusaLink(client, host, username, password)


async def test_get_version(printer):
result = await printer.get_version()
assert "api" in result


async def test_get_info(printer):
result = await printer.get_info()
assert "serial" in result
assert "nozzle_diameter" in result


async def test_get_status(printer):
result = await printer.get_status()
assert "printer" in result
assert "state" in result["printer"]


async def test_get_job(printer):
result = await printer.get_job()
# Returns empty dict when no job is running — both states are valid
assert isinstance(result, dict)
if result:
assert "id" in result
assert "state" in result


async def test_get_legacy_printer(printer):
result = await printer.get_legacy_printer()
assert isinstance(result, dict)