e62ece1c06
- FastAPI app with CORS, lifespan handlers - Pydantic Settings config (DB, Redis, CORS, SMTP, JWT, Rentman) - SQLAlchemy async engine + session (DeclarativeBase) - 6 DB models: EquipmentCache, RentalRequest, RentalRequestItem, Contact, AdminUser, SyncLog - Pydantic schemas: EquipmentItem, EquipmentDetail, PaginatedEquipment, ContactCreate, ContactResponse - Redis cache helper: set/get/delete_pattern, rate limiting, equipment key builders - Equipment router: list (search/category/sort/pagination), detail, categories – all cached - Contact router: POST with Pydantic validation + rate limiting (5/min) - Health router: GET /api/health with DB + Redis status - 28 pytest tests (all pass, 90% coverage) - Dockerfile, requirements.txt, pytest.ini, test_report.md
3.1 KiB
3.1 KiB
Test Report – T03 Backend Core
Task
T03: Backend Core – FastAPI + DB Models + Equipment API + Redis Cache + Health
Date
2026-07-09
Test Commands Run
1. pytest (all tests)
cd backend && python -m pytest tests/ -v --cov=app --cov-report=term-missing
2. App import check
cd backend && python -c 'from app.main import app; print(app.title)'
Output: HMS Licht & Ton API
Test Results
28 tests, all passed, 0 warnings
| Test File | Tests | Status |
|---|---|---|
| test_cache.py | 8 | ALL PASS |
| test_contact_router.py | 5 | ALL PASS |
| test_equipment_router.py | 9 | ALL PASS |
| test_health.py | 1 | ALL PASS |
| test_models.py | 5 | ALL PASS |
Coverage Report
Name Stmts Miss Cover Missing
------------------------------------------------------------
app/__init__.py 0 0 100%
app/cache.py 62 13 79%
app/config.py 19 0 100%
app/database.py 11 2 82%
app/main.py 18 3 83%
app/models/__init__.py 6 0 100%
app/models/admin_user.py 10 0 100%
app/models/contact.py 14 0 100%
app/models/equipment.py 22 0 100%
app/models/rental_request.py 40 0 100%
app/models/sync_log.py 15 0 100%
app/routers/__init__.py 0 0 100%
app/routers/contact.py 17 1 94%
app/routers/equipment.py 60 15 75%
app/routers/health.py 17 3 82%
app/schemas/__init__.py 3 0 100%
app/schemas/contact.py 16 0 100%
app/schemas/equipment.py 33 0 100%
------------------------------------------------------------
TOTAL 363 37 90%
Overall coverage: 90% (target: 80%)
Acceptance Criteria Verification
- ✅ GET /api/health returns 200 with status, db, redis fields
- ✅ GET /api/equipment returns 200 with paginated response (items, total, page, page_size, total_pages)
- ✅ GET /api/equipment?search=K2 returns only matching items
- ✅ GET /api/equipment?category=Lautsprecher returns only matching items
- ✅ GET /api/equipment?sort=name_desc returns items sorted descending
- ✅ GET /api/equipment/categories returns 200 with array of category strings
- ✅ GET /api/equipment/{id} returns 200 with full equipment detail for valid ID
- ✅ GET /api/equipment/999999 returns 404
- ✅ Redis caches equipment list (via fakeredis test)
- ✅ All 6 DB models defined with correct columns and indexes
- ✅ POST /api/contact returns 201 with valid data
- ✅ POST /api/contact returns 422 with invalid email
- ✅ POST /api/contact returns 422 with privacy_consent=False
- ✅ Rate limiting active (6th request returns 429)
Smoke Test
- App starts:
python -c 'from app.main import app; print(app.title)'→ "HMS Licht & Ton API" - All endpoints tested via ASGITransport with in-memory SQLite + fakeredis
- No real Redis or PostgreSQL needed for tests