Files
hms-licht-ton/backend/test_report.md
T
A0 Implementation Engineer e62ece1c06 feat: T03 backend core – FastAPI + DB models + Equipment API + Redis cache + health + tests
- 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
2026-07-09 01:26:45 +02:00

84 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
1. ✅ GET /api/health returns 200 with status, db, redis fields
2. ✅ GET /api/equipment returns 200 with paginated response (items, total, page, page_size, total_pages)
3. ✅ GET /api/equipment?search=K2 returns only matching items
4. ✅ GET /api/equipment?category=Lautsprecher returns only matching items
5. ✅ GET /api/equipment?sort=name_desc returns items sorted descending
6. ✅ GET /api/equipment/categories returns 200 with array of category strings
7. ✅ GET /api/equipment/{id} returns 200 with full equipment detail for valid ID
8. ✅ GET /api/equipment/999999 returns 404
9. ✅ Redis caches equipment list (via fakeredis test)
10. ✅ All 6 DB models defined with correct columns and indexes
11. ✅ POST /api/contact returns 201 with valid data
12. ✅ POST /api/contact returns 422 with invalid email
13. ✅ POST /api/contact returns 422 with privacy_consent=False
14. ✅ 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