mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Generate property reference to uprn map from csv bytes 🟥
This commit is contained in:
parent
dd31c2d945
commit
b143169659
4 changed files with 42 additions and 14 deletions
9
backend/condition/lookups/uprn_lookup_csv.py
Normal file
9
backend/condition/lookups/uprn_lookup_csv.py
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
33
backend/condition/tests/lookups/test_uprn_lookup_csv.py
Normal file
33
backend/condition/tests/lookups/test_uprn_lookup_csv.py
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue