Model/tests/condition/lookups/test_uprn_lookup_csv.py
Khalim Conn-Kowlessar 735e83cef2 Relocate condition-data ingestion into the DDD layout 🟪
Behaviour-preserving lift-and-shift of the condition module out of legacy
backend/condition/ into domain/condition, infrastructure/condition,
infrastructure/postgres/condition_tables.py, repositories/condition,
applications/condition, and tests/condition. Imports rewritten to the DDD
paths; ConditionPostgres and the ORM models keep the legacy backend.app.db
Base/db_session bridges so the existing suite proves behaviour is unchanged
(SQLModel + session-DI conversion tracked as a follow-up in ADR-0064).

16 condition tests pass at the new location.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 14:51:25 +00:00

34 lines
915 B
Python

import pytest
from typing import Dict
from tempfile import NamedTemporaryFile
from infrastructure.condition.lookups.uprn_lookup_csv import UprnLookupLocal
@pytest.fixture
def prop_ref_uprn_csv_file() -> str:
csv_content = """reference,out_uprn
ABC123,10000000001
DEF456,10000000002
GHI789,10000000003
"""
with NamedTemporaryFile(mode="w+", delete=False, suffix=".csv") as tmp:
tmp.write(csv_content)
tmp.flush()
return tmp.name
def test_generate_prop_ref_uprn_from_csv_file(prop_ref_uprn_csv_file: str) -> None:
# arrange
uprn_lookup = UprnLookupLocal(prop_ref_uprn_csv_file)
expected_map: Dict[str, int] = {
"ABC123": 10000000001,
"DEF456": 10000000002,
"GHI789": 10000000003,
}
# act
actual_map: Dict[str, int] = uprn_lookup.get_property_ref_to_uprn_lookup()
# assert
assert actual_map == expected_map