-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Overview
Add comprehensive integration tests for EmploymentService to verify database behavior, constraints, and data persistence beyond what unit tests cover.
Context
EmploymentService has specific SQLite constraints that need testing:
CHECK(end IS NULL OR end >= start)(to mark boolean values)UNIQUE(company, start)
Test Scenarios to Implement
1. Database Constraints Enforcement
- Test UNIQUE constraint prevents duplicate (company, start) at DB level
- Test CHECK constraint enforces
endisnullor >=startvalues - Test constraint violations even when bypassing service validation
2. Data Type Conversion & Serialization
- Test date serialization roundtrip (Python date → SQLite TEXT → Python date)
- Test accepting ISO date strings ("2025-07-21")
- Test accepting date objects
- Test empty notes field (NULL vs "")
3. Transaction Behavior
- Test rollback when duplicate travel added
- Test successful commit for valid travel
- Test multiple operations in single transaction
4. Query Behavior
- Test
find()with start filter - Test
find()with end filter - Test
find()with compant filter - Test
find()with multiple filters combined - Test case handling (service uppercases input)
5. Schema & ID Management
- Verify employment table created with all constraints
- Test AUTOINCREMENT assigns sequential IDs
- Test ID doesn't reuse after deletion
6. Edge Cases
- Test notes field with special characters and Unicode
Files to Create/Modify
-
tests/integration/test_work_service_integration.py
Acceptance Criteria
- All 20+ test scenarios implemented
- Tests use
fake_dbfixture - All tests pass consistently
Notes
Existing integration tests in tests/integration/test_employment_service_integration.py cover basic scenarios. This issue tracks expansion to comprehensive database behavior testing.
Reactions are currently unavailable