Skip to content

Testing

t957095 edited this page Jun 15, 2026 · 1 revision

Testing

ShelfWise includes multiple testing tiers, from fully local to full Azure OpenAI integration.

Test Structure

tests/
├── test_api.py              # FastAPI endpoint tests
├── test_scraper.py          # Scraper unit tests
├── test_agent.py            # Reasoning agent tests
└── test_image_verifier.py   # Image verification tests

Running Tests

# All tests
pytest tests/ -v

# With coverage
pytest tests/ --cov=backend --cov-report=term-missing

Linting and Formatting

ruff check backend/
ruff format --check backend/

Testing Tiers

Tier 1: Local Deterministic Mode (No API Keys)

This is the default mode. All reasoning, image verification, and knowledge graph operations run locally.

cd backend
python -m uvicorn main:app --host 127.0.0.1 --port 8000
python scripts/test_foundry_iq.py

What to verify:

  • /api/health returns ok.
  • Demo products load successfully.
  • Batch processing completes for known UPCs.
  • Exports produce valid files.

Tier 2: GitHub Models

Use GitHub Models for free or low-cost LLM enrichment.

FOUNDRY_ENDPOINT=https://models.inference.ai.azure.com
FOUNDRY_API_KEY=ghp_your_token
FOUNDRY_MODEL=gpt-4.1-mini

Verify that foundry_enriched is true on enriched products.

Tier 3: Ollama Local LLM

Run a local model for private enrichment.

ollama run llama3.1
FOUNDRY_ENDPOINT=http://localhost:11434/v1
FOUNDRY_API_KEY=ollama
FOUNDRY_MODEL=llama3.1

Tier 4: Azure OpenAI

Production-grade enrichment with Microsoft Foundry IQ.

FOUNDRY_ENDPOINT=https://your-resource.openai.azure.com/openai/deployments/your-deployment
FOUNDRY_API_KEY=your-azure-key
FOUNDRY_MODEL=gpt-4o

Run backend/setup-azure-openai.ps1 to provision resources.

Manual QA Checklist

  • App loads at /app.
  • Demo button populates products.
  • UPC batch processes with live progress.
  • CSV upload starts a job.
  • Product cards render image, name, brand, category, confidence.
  • Reasoning trace modal opens and displays citations.
  • Search filters products correctly.
  • Sort toggles ascending/descending.
  • Export buttons download valid files.
  • Keyboard shortcuts work.
  • Reduced motion and high contrast modes are respected.

CI/CD

GitHub Actions runs on every push and PR:

  1. Ruff lint
  2. Ruff format check
  3. pytest suite
  4. Import checks
  5. Docker build

Matrix: Python 3.12, 3.13, 3.14.

Performance Testing

Use the /api/metrics endpoint to monitor:

  • Per-source success rate and latency
  • Cache hit rate
  • Reasoning agent duration
  • Image verification duration

Reporting Bugs

When filing an issue, include:

  1. Steps to reproduce
  2. Expected vs actual behavior
  3. UPC(s) that trigger the issue
  4. Relevant logs or screenshots
  5. Whether API keys were configured

Clone this wiki locally