Skip to content

[Integration Test] EmploymentService #7

@adnanvaldes

Description

@adnanvaldes

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 end is null or >= 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_db fixture
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions