Skip to content

[Integration Test] AddressService #8

@adnanvaldes

Description

@adnanvaldes

Overview

Add comprehensive integration tests for AddressService to verify database behavior, constraints, and data persistence beyond what unit tests cover.

Context

AddressService has specific SQLite constraints that need testing:

  • CHECK(end IS NULL OR end >= start) (to mark boolean values)
  • UNIQUE(street, city, start, end)

Test Scenarios to Implement

1. Database Constraints Enforcement

  • Test UNIQUE constraint prevents duplicate (street, city, start, end) 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 address added
  • Test successful commit for valid address
  • Test multiple operations in single transaction

4. Query Behavior

  • Test find() with start filter
  • Test find() with end filter
  • Test find() with street filter
  • Test find() with city filter
  • Test find() with multiple filters combined
  • Test case handling (service uppercases input)

5. Schema & ID Management

  • Verify address 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_address_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_address_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