diff --git a/backend/condition/lookups/uprn_lookup_csv.py b/backend/condition/lookups/uprn_lookup_csv.py new file mode 100644 index 00000000..5f84587a --- /dev/null +++ b/backend/condition/lookups/uprn_lookup_csv.py @@ -0,0 +1,9 @@ +from typing import BinaryIO, Dict +from backend.condition.lookups.uprn_lookup import UprnLookup + + +class UprnLookupCsv(UprnLookup): + def get_location_ref_to_uprn_map( + self, lookup_file_stream: BinaryIO + ) -> Dict[str, int]: + raise NotImplementedError diff --git a/backend/condition/lookups/uprn_lookup_local.py b/backend/condition/lookups/uprn_lookup_local.py deleted file mode 100644 index 7bf7a575..00000000 --- a/backend/condition/lookups/uprn_lookup_local.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Dict -from backend.condition.lookups.uprn_lookup import UprnLookup - - -class UprnLookupLocal(UprnLookup): - def get_location_ref_to_uprn_map(self, lookup_filepath: str) -> Dict[str, int]: - raise NotImplementedError diff --git a/backend/condition/lookups/uprn_lookup_s3.py b/backend/condition/lookups/uprn_lookup_s3.py deleted file mode 100644 index e73bffaf..00000000 --- a/backend/condition/lookups/uprn_lookup_s3.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import Dict -from backend.condition.lookups.uprn_lookup import UprnLookup - - -class UprnLookupS3(UprnLookup): - def get_location_ref_to_uprn_map(self, lookup_filepath: str) -> Dict[str, int]: - raise NotImplementedError diff --git a/backend/condition/tests/lookups/test_uprn_lookup_csv.py b/backend/condition/tests/lookups/test_uprn_lookup_csv.py new file mode 100644 index 00000000..67cb80b9 --- /dev/null +++ b/backend/condition/tests/lookups/test_uprn_lookup_csv.py @@ -0,0 +1,33 @@ +from typing import Any, Dict +import pytest +from io import BytesIO + +from backend.condition.lookups.uprn_lookup_csv import UprnLookupCsv + + +@pytest.fixture +def prop_ref_uprn_csv_bytes() -> BytesIO: + csv_bytes = b"""reference, out_uprn + ABC123,10000000001 + DEF456,10000000002 + GHI789,10000000003 + """ + return BytesIO(csv_bytes) + + +def test_generate_prop_ref_uprn_from_csv_bytes(prop_ref_uprn_csv_bytes) -> None: + # arrange + uprn_lookup = UprnLookupCsv() + expected_map: Dict[str, int] = { + "ABC123": 10000000001, + "DEF456": 10000000002, + "GHI789": 10000000003, + } + + # act + actual_map: Dict[str, int] = uprn_lookup.get_location_ref_to_uprn_map( + prop_ref_uprn_csv_bytes + ) + + # assert + assert actual_map == expected_map