Skip to content

refactor: migrate tests and documentation to use pytest - #177

Closed
acai10 wants to merge 7 commits into
danieldeer:developmentfrom
acai10:test/migrate-suite-to-pytest
Closed

acai10 wants to merge 7 commits into
danieldeer:developmentfrom
acai10:test/migrate-suite-to-pytest

Conversation

@acai10

@acai10 acai10 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Completes the pytest migration of the test suite. Closes #167.

tests/test_api.py and tests/test_error_handling.py were already pytest-native; tests/test_e2e.py and tests/test_health.py were still class-based with manual setup and teardown. Both are now plain test functions using fixtures.

Primarily a test-suite refactor plus the documentation and CI updates listed in #167; no runtime behavior changes.

Key Changes:

  • tests/test_e2e.py and tests/test_health.py: module-level test functions with tmp_path/monkeypatch fixtures, plain assert statements, no hand-rolled cleanup.
  • .github/workflows/e2e.yml: runs uv run pytest tests/test_e2e.py -v.
  • Docs: uv run pytest documented in docs/testing.md, a new Testing section in docs/development.md, and the command added to the pre-PR checks in docs/contributing.md.
  • flake.nix: adds pytest and httpx so the suite is runnable in the dev shell.
  • No dependency changes — pytest was already in pyproject.toml and uv.lock.

Validation:

uv sync --locked # Resolved 51 packages, Checked 50 packages
uv run pytest # 41 passed
uv run pytest tests/test_e2e.py # passed (mirrors the E2E workflow)
uv run ruff check . # All checks passed!
uv run ruff format --check . # 19 files already formatted

The same 41 tests pass before and after, with the migrated files keeping their original test count and assertions.

Not verified: the flake.nix change.

Persistent Warnings

StarletteDeprecationWarning: Using httpx with starlette.testclient is deprecated; install httpx2 instead.
DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.

Might be worth to upgrade in a future PR.

@acai10

acai10 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

A few things I noticed while migrating, but deliberately left alone, they
all predate this PR and have nothing to do with the pytest switch. This one
just moves the existing tests over without touching what they cover.

Biggest one: cache.load()'s corrupt-file handling isn't tested at all.
Broken JSON, JSON that isn't an object, invalid UTF-8, all three move the
file to .sdb.corrupt-<timestamp> and start fresh. It works, but nothing
pins it down, and that's the path that touches user data. It's not in
docs/persistence.md either.

Also, test_unloaded_database_returns_503 hasn't kept up: /db/count,
/db/bulk and HEAD /db are missing from the list. They do return 503,
nobody checks.

And there's no conftest.py, every module has its own client fixture and
they've drifted apart. Consolidating them would be the natural end of the
migration, but it'd blow up this PR.

Happy to open a follow-up issue if that's easier to track.

@AnnoDomine

Copy link
Copy Markdown
Contributor

@acai10
Could you change the target branch to the development branch?
Even though we are removing active maintenance of the API integration, migrating the legacy tests to pytest is a good foundation for further development.

@acai10
acai10 changed the base branch from main to development September 18, 2026 10:36
@danieldeer
danieldeer deleted the branch danieldeer:development September 20, 2026 08:23
@danieldeer danieldeer closed this Sep 20, 2026
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.

Migrate the test suite from unittest to pytest

3 participants