Files

89 lines
3.1 KiB
Markdown

# Test Report - T08: Bildretusche + Preisvergleich
## Backend Tests
**Command:** `cd backend && python -m pytest tests/test_retouch.py --cov=app.services.retouch_service --cov=app.routers.image_retouch --cov-report=term-missing -v`
**Result:** 38 passed, 0 failed
### Coverage
| Module | Stmts | Miss | Cover |
|--------|-------|------|-------|
| app/routers/image_retouch.py | 52 | 16 | 69% |
| app/services/retouch_service.py | 132 | 5 | 96% |
| **TOTAL** | **184** | **21** | **89%** |
### Test Categories
#### TestRetouchService (20 tests)
- validate_mime_type_valid/invalid
- validate_file_size_valid/too_large
- generate_retouch_prompt_default/with_vehicle_info
- upload_retouch_file_success/invalid_mime/too_large
- get_result_not_found
- list_results_empty/with_data/filter_by_vehicle
- process_retouch_success (mocked Flux.1-Pro)
- process_retouch_failure (OpenRouter unavailable → status=failed)
- process_retouch_not_found
- _call_flux_pro_no_api_key
- _call_flux_pro_success_data_uri (base64 response)
- _call_flux_pro_success_list_content (list content parts)
- _call_flux_pro_fallback_original_bytes (no image in response)
#### TestPriceCompareService (4 tests)
- compare_prices_success (listings + average_price)
- compare_prices_vehicle_not_found
- compare_prices_listings_have_correct_make_model
- compare_prices_average_calculation
#### TestRetouchRouter (14 tests)
- POST /retouch/process → 202 + retouch_id (valid image)
- POST /retouch/process → 422 (no file)
- POST /retouch/process → 422 (invalid MIME)
- POST /retouch/process → 202 (with vehicle_id)
- GET /retouch/results/:id → 200 (completed)
- GET /retouch/results/:id → 200 (processing)
- GET /retouch/results/:id → 200 (failed + error_message)
- GET /retouch/results/:id → 404 (not found)
- POST /retouch/price-compare → 200 (success)
- POST /retouch/price-compare → 422 (no vehicle_id)
- POST /retouch/price-compare → 404 (vehicle not found)
- POST /retouch/process → 401 (unauthorized)
- GET /retouch/results/:id → 401 (unauthorized)
- POST /retouch/price-compare → 401 (unauthorized)
## Frontend Tests
**Command:** `cd frontend && npx vitest run tests/retouch.test.tsx`
**Result:** 13 passed, 0 failed
### Test Categories
#### RetouchUpload (5 tests)
- renders drag-and-drop zone
- shows file input with image accept
- shows error for non-image file
- uploads image file successfully (mocked fetch)
- shows error on upload failure
#### BeforeAfterSlider (3 tests)
- renders both images (before + after)
- renders labels (Original / Retuschiert)
- renders slider handle
#### PriceComparison (5 tests)
- renders vehicle ID input and compare button
- shows error when comparing without vehicle ID
- fetches and displays comparable listings (mocked apiFetch)
- shows empty state when no listings found
- shows error on fetch failure
## Smoke Test
- Backend: App imports successfully, router registered at /api/v1/retouch
- Frontend: All 3 components render without errors in test environment
- OpenRouter mocked in all backend tests (no real API calls)
- Background task mocked in router integration tests (avoids event loop conflicts)