oliver-sales-ops-platform/backend/tests/__init__.py
DJP 5ad6d01846 Add pytest integration test harness for backend
Test harness hits the live backend on http://localhost:8003 (override via
OSOP_BASE_URL) rather than spinning an in-process FastAPI app, so we test
the actual deployed surface. 33 tests pass, 1 intentionally skipped
(real Anthropic-backed intake — gated behind @pytest.mark.requires_anthropic
to avoid spending money on every run).

Coverage:
- Opportunity CRUD: create with defaults + invalid model_type, all 5
  model_type values round-trip, list/get/update, full create-delete-404.
- Stage machine: 17 rows initialised, advance unlocks next, double-complete
  rejected, out-of-order rejected, out-of-range rejected, notes persist.
- Stage gating: stage 3 without approvals returns 400 with "approval"/
  "gated" in the detail and does not mutate state.
- File upload: .txt, .md, synthesized .docx, synthesized .xlsx all
  upload + extract; .exe rejected; list/delete round-trip.
- Schema sanity: list endpoints return the expected shape.

Re-run:
  python3 -m venv /tmp/osop_test_venv && \
    /tmp/osop_test_venv/bin/pip install -q -r backend/requirements-dev.txt && \
    cd backend && /tmp/osop_test_venv/bin/pytest tests/ -v

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 13:22:32 -04:00

0 lines
Python