2.9 KiB
2.9 KiB
Test Report – T04: Rentman Integration + Admin Auth
Datum: 2026-07-09 Task: T04 (Rentman Integration: Import + Request + Admin Auth) Projekt: hms-licht-ton
Test Commands Run
cd backend && python -m pytest tests/ -v --cov=app --cov-report=term-missing
Results
- Total tests: 34
- Passed: 34
- Failed: 0
- Coverage: 71% overall
Test Breakdown
test_admin_auth.py (9 tests) – T04
- test_password_hash_and_verify ✅
- test_create_and_verify_token ✅
- test_verify_invalid_token ✅
- test_verify_expired_token ✅
- test_login_success (valid creds → 200 + token) ✅
- test_login_failure_wrong_password (→ 401) ✅
- test_login_failure_unknown_user (→ 401) ✅
- test_me_without_token (→ 401) ✅
- test_me_with_valid_token (→ 200 + username) ✅
test_admin_router.py (6 tests) – T04
- test_sync_without_token (→ 401) ✅
- test_sync_status_without_token (→ 401) ✅
- test_sync_log_without_token (→ 401) ✅
- test_sync_with_valid_token (→ 200 + sync_id) ✅
- test_sync_status_with_valid_token (→ 200 + status) ✅
- test_sync_log_with_valid_token (→ 200 + paginated) ✅
test_rentman_import.py (5 tests) – T04
- test_transform_equipment (field mapping) ✅
- test_paginated_import (250 items, 3 pages, upsert verified) ✅
- test_sync_upsert_existing (update not duplicate) ✅
- test_sync_failure_logs_error (error logged in sync_log) ✅
- test_get_all_equipment_paginates (iterates until data empty) ✅
test_rentman_request.py (5 tests) – T04
- test_build_project_request_payload (full field mapping) ✅
- test_build_project_request_payload_no_company (fallback to contact_name) ✅
- test_build_equipment_payload (equipment mapping with linked_equipment) ✅
- test_projectrequest_success (mock POST returns ID) ✅
- test_equipment_retry (3 retries with exponential backoff) ✅
test_equipment_router.py (8 tests) – T03
- test_list_equipment (paginated response) ✅
- test_search_equipment (filter by name) ✅
- test_filter_category (filter by category) ✅
- test_sort_name_asc ✅
- test_sort_name_desc ✅
- test_categories (distinct categories) ✅
- test_equipment_detail (full detail) ✅
- test_equipment_not_found (404) ✅
test_health.py (1 test) – T03
- test_health_endpoint (status, db, redis) ✅
Coverage by Module
| Module | Coverage |
|---|---|
| app/auth.py | 86% |
| app/routers/admin.py | 84% |
| app/services/sync_service.py | 82% |
| app/services/rentman_service.py | 75% |
| app/routers/equipment.py | 66% |
| app/main.py | 64% |
| app/routers/health.py | 60% |
| app/models/* | 100% |
| app/schemas/* | 76-100% |
| app/config.py | 100% |
Notes
- Rentman API fully mocked in tests (no live calls)
- Redis cache fully mocked in tests
- SQLite in-memory database used for tests
- APScheduler startup tested via lifespan context
- Rate limiting tested via mock counter