team-24

Testing Strategy

Overview

Orderly uses pytest for all automated testing across both backend services. Tests are co-located with the service source code and run in CI on every push to main and on every pull request.


Test Locations

Service Test directory
Recommender backend src/backend/tests/
Upload / OCR backend src/upload-menu-backend/tests/

Critical Modules

The following modules contain core product logic and must each maintain at least 30% automated line coverage.

Module Role Test file
src/backend/budget_filter.py Filters dishes by max budget — safety-critical post-filter tests/test_budget_filter.py
src/backend/order_history.py In-memory order history store — thread safety required tests/test_history_router.py
src/backend/parser.py Parses OCR raw text into structured menu items tests/test_parser.py
src/upload-menu-backend/main.py File upload + Tesseract OCR endpoint tests/test_upload.py

Unit Tests

Unit tests verify individual functions and modules in isolation.

Integration Tests

Integration tests verify interactions between components using FastAPI’s TestClient.

Quality Requirement Tests

See docs/quality-requirement-tests.md for automated QRTs linked to each quality requirement.


Additional QA Check — Bandit (Security Static Analysis)

Tool: Bandit — static security analysis for Python

QA objective: Detect common security vulnerabilities in Python source code (e.g. hardcoded credentials, unsafe use of eval, insecure subprocess calls, SQL injection patterns).

Why this risk matters: Orderly’s backends handle user-supplied file uploads, AI-generated text, and HTTP headers used as user IDs. Without static security analysis, subtle vulnerabilities (e.g. path traversal in file upload, shell injection in OCR calls) could go undetected until exploitation.

Where it runs: CI pipeline — bandit -r src/backend src/upload-menu-backend -ll (medium and high severity only, to avoid noise from low-severity informational findings).

Limitations:


Running Tests Locally

# Recommender backend
cd src/backend
pip install -r requirements.txt
pytest tests/ -v --tb=short

# Upload backend
cd src/upload-menu-backend
pip install -r requirements.txt
pytest tests/ -v --tb=short

# Coverage report (recommender backend)
cd src/backend
pytest tests/ --cov=. --cov-report=term-missing

# Security scan
pip install bandit
bandit -r src/backend src/upload-menu-backend -ll

Coverage Expectations