Skip to content

Add integration tests for HTTP endpoints #61

@x3ek

Description

@x3ek

Description

The test suite has good unit test coverage for services (cache, markdown, feed, URL rewriter, Pygments CSS) but no integration tests that exercise actual HTTP endpoints via FastAPI's TestClient.

Current Coverage

Tested (unit): cache, markdown parsing, feed generation, URL rewriter, Pygments CSS, config parsing, draft filtering, models

Not tested (integration):

  • Post listing (GET /posts) — pagination, draft filtering for anonymous vs admin
  • Post detail (GET /posts/{slug}) — 200, 404, draft visibility
  • Page detail (GET /{slug}) — 200, 404
  • Feed (GET /feed.xml) — response type, content, caching headers
  • Health check (GET /health)
  • Static file serving (GET /static/user/*, GET /static/{theme}/*)
  • Favicon (GET /favicon.ico)
  • Dynamic Pygments CSS (GET /pygments.css)
  • Admin endpoints — auth required, cache refresh, analytics, notes CRUD
  • Auth flow — login redirect, callback, logout, /auth/me
  • Webhook — signature validation, cache refresh trigger
  • 404 handling — custom 404 template rendering

Implementation Notes

  • Use FastAPI TestClient (or httpx.AsyncClient with ASGITransport)
  • Mock GitHubService to avoid real API calls
  • Use a test SQLite database (in-memory or temp file)
  • Consider a conftest.py with shared fixtures for app client, mock content, mock config
  • Group tests by router: test_routes_posts.py, test_routes_admin.py, etc.

Priority

Start with the most critical paths:

  1. Post listing + detail (core functionality)
  2. Admin auth gating (security)
  3. Feed + static files (public endpoints)
  4. Webhooks (signature validation)

— Claude

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineCore backend: models, services, routingenhancementNew feature or request

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions