Skip to content

Document-processing tests

Document-processing tests

Use these suites when changing upload, status, processing, or edit-history behavior.

Key suites

  • api/tests/test_document_edit_audit.py — edit diff computation, one-time patch restriction, status gating, and audit creation.
  • api/tests/test_edit_history.py — persistence and response shaping for edit_history.
  • tests/integration/test_document_processing.py — upload and status path integration.
  • tests/integration/test_async_document_processing.py — Celery-backed polling flow.
  • tests/unit/processing/test_upload_validation.py — upload validation rules.
  • tests/unit/processing/test_document_classification_toggle.py — classification behavior switch.

What these tests prove

  • edit_history is saved and accumulated correctly
  • edited_by is derived from the authenticated user rather than the client payload
  • completed documents cannot be patched arbitrarily
  • task polling reads the persisted processing row
  • upload validation rejects malformed requests early

Minimal validation

Prefer the smallest test slice that matches the code path:

  • request validation only → tests/unit/processing/test_upload_validation.py
  • edit history or audit semantics → api/tests/test_document_edit_audit.py and api/tests/test_edit_history.py
  • queue/poll behavior → tests/integration/test_async_document_processing.py