-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Overview
Add comprehensive integration tests for TravelService to verify database behavior, constraints, and data persistence beyond what unit tests cover.
Context
TravelService has specific SQLite constraints that need testing:
CHECK(length(origin) = 3 AND origin = UPPER(origin))CHECK(length(destination) = 3 AND destination = UPPER(destination))UNIQUE(origin, destination, date)
Test Scenarios to Implement
1. Database Constraints Enforcement
- Test UNIQUE constraint prevents duplicate (origin, destination, date) at DB level
- Test CHECK constraint enforces 3-letter uppercase origin codes
- Test CHECK constraint enforces 3-letter uppercase destination codes
- 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 invalid country code provided
- Test rollback when duplicate travel added
- Test successful commit for valid travel
- Test multiple operations in single transaction
4. Query Behavior
- Test
find()with origin filter - Test
find()with destination filter - Test
find()with date filter - Test
find()with multiple filters combined - Test case handling (service uppercases input)
5. Schema & ID Management
- Verify travel table created with all constraints
- Test AUTOINCREMENT assigns sequential IDs
- Test ID doesn't reuse after deletion
6. Edge Cases
- Test with whitespace in country codes
- Test with lowercase country codes (should be uppercased)
- Test notes field with special characters and Unicode
- Test historical dates (1900-01-01) and future dates
Files to Create/Modify
-
tests/integration/test_travel_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_travel_service_integration.py cover basic scenarios. This issue tracks expansion to comprehensive database behavior testing.
Reactions are currently unavailable