mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Consolidate three-tier matching and tidy test ordering 🟪
This commit is contained in:
parent
9a04d89cae
commit
16af543560
2 changed files with 23 additions and 20 deletions
|
|
@ -90,13 +90,16 @@ class PashubClient:
|
|||
if file.evidence_category is not None and file.evidence_category.lower() == "retrofit design":
|
||||
return CoreFiles.RETROFIT_DESIGN_DOC
|
||||
|
||||
if CoreFiles.IMPROVEMENT_OPTION_EVALUATION.value in file.file_name:
|
||||
return CoreFiles.IMPROVEMENT_OPTION_EVALUATION
|
||||
|
||||
if CoreFiles.MEDIUM_TERM_IMPROVEMENT_PLAN.value in file.file_name:
|
||||
return CoreFiles.MEDIUM_TERM_IMPROVEMENT_PLAN
|
||||
for core_file in (
|
||||
CoreFiles.IMPROVEMENT_OPTION_EVALUATION,
|
||||
CoreFiles.MEDIUM_TERM_IMPROVEMENT_PLAN,
|
||||
):
|
||||
if core_file.value in file.file_name:
|
||||
return core_file
|
||||
|
||||
for core_file in CoreFiles:
|
||||
if core_file is CoreFiles.RETROFIT_DESIGN_DOC:
|
||||
continue
|
||||
if file.file_name.startswith(core_file.value):
|
||||
return core_file
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -45,6 +45,21 @@ def test_get_core_file_type_returns_retrofit_design_doc_for_evidence_category()
|
|||
assert result == CoreFiles.RETROFIT_DESIGN_DOC
|
||||
|
||||
|
||||
def test_get_core_file_type_evidence_category_match_is_case_insensitive() -> None:
|
||||
# Arrange
|
||||
client = make_client()
|
||||
file = make_file(
|
||||
file_name="2512-OSM-H21M900-XX-DR-N-A_Lord Nelson Street 018.pdf",
|
||||
evidence_category="Retrofit Design",
|
||||
)
|
||||
|
||||
# Act
|
||||
result = client._get_core_file_type(file)
|
||||
|
||||
# Assert
|
||||
assert result == CoreFiles.RETROFIT_DESIGN_DOC
|
||||
|
||||
|
||||
def test_get_core_file_type_returns_improvement_option_evaluation_via_substring() -> None:
|
||||
# Arrange
|
||||
client = make_client()
|
||||
|
|
@ -183,18 +198,3 @@ def test_select_latest_core_files_falls_back_to_latest_when_no_osm_candidates()
|
|||
|
||||
# Assert
|
||||
assert result[CoreFiles.RETROFIT_DESIGN_DOC].file_name == "retrofit_design_v2.pdf"
|
||||
|
||||
|
||||
def test_get_core_file_type_evidence_category_match_is_case_insensitive() -> None:
|
||||
# Arrange
|
||||
client = make_client()
|
||||
file = make_file(
|
||||
file_name="2512-OSM-H21M900-XX-DR-N-A_Lord Nelson Street 018.pdf",
|
||||
evidence_category="Retrofit Design",
|
||||
)
|
||||
|
||||
# Act
|
||||
result = client._get_core_file_type(file)
|
||||
|
||||
# Assert
|
||||
assert result == CoreFiles.RETROFIT_DESIGN_DOC
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue