mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
get_evidence_files_by_job_id returns DownloadedFiles with empty other when include_other=False 🟥
This commit is contained in:
parent
a1620f5015
commit
15e37ef0e0
2 changed files with 47 additions and 1 deletions
|
|
@ -18,6 +18,11 @@ class _EvidenceFileGroups(NamedTuple):
|
|||
other: List[EvidenceFileData]
|
||||
|
||||
|
||||
class DownloadedFiles(NamedTuple):
|
||||
core: List[str]
|
||||
other: List[str]
|
||||
|
||||
|
||||
class UnauthorizedError(Exception):
|
||||
pass
|
||||
|
||||
|
|
@ -75,6 +80,11 @@ class PashubClient:
|
|||
|
||||
return saved_files
|
||||
|
||||
def get_evidence_files_by_job_id(
|
||||
self, job_id: str, include_other: bool = False
|
||||
) -> DownloadedFiles:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_uprn_by_job_id(self, job_id: str) -> Optional[str]:
|
||||
logger.info(f"Getting UPRN for job ID {job_id}")
|
||||
url = f"{self.base}/jobs/{job_id}"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,18 @@
|
|||
# pyright: reportPrivateUsage=false
|
||||
from typing import Optional
|
||||
from unittest.mock import patch
|
||||
|
||||
from backend.pashub_fetcher.core_files import CoreFiles
|
||||
from backend.pashub_fetcher.evidence_file_data import EvidenceFileData
|
||||
from backend.pashub_fetcher.pashub_client import PashubClient
|
||||
from backend.pashub_fetcher.evidence_metadata import EvidenceMetadata
|
||||
from backend.pashub_fetcher.pashub_client import DownloadedFiles, PashubClient
|
||||
|
||||
|
||||
def make_metadata() -> EvidenceMetadata:
|
||||
return EvidenceMetadata(
|
||||
container_name="my-container",
|
||||
blob_uri="https://storage.example.com/blob?sas=token",
|
||||
)
|
||||
|
||||
|
||||
def make_client() -> PashubClient:
|
||||
|
|
@ -131,3 +140,30 @@ def test_group_into_core_and_other_files_falls_back_to_latest_when_no_osm_candid
|
|||
|
||||
# Assert
|
||||
assert result.core[CoreFiles.RETROFIT_DESIGN_DOC].file_name == "retrofit_design_v2.pdf"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_evidence_files_by_job_id
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_get_evidence_files_by_job_id_returns_downloaded_files_with_empty_other_when_include_other_false() -> None:
|
||||
# Arrange
|
||||
client = make_client()
|
||||
files = [
|
||||
make_file(file_name="SiteNote_001.pdf"),
|
||||
make_file(file_name="unknown_doc.pdf"),
|
||||
]
|
||||
|
||||
# Act
|
||||
with (
|
||||
patch.object(client, "_get_evidence_list", return_value=files),
|
||||
patch.object(client, "_get_evidence_metadata", return_value=make_metadata()),
|
||||
patch.object(client, "_download_file"),
|
||||
):
|
||||
result = client.get_evidence_files_by_job_id("job-1", include_other=False)
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, DownloadedFiles)
|
||||
assert result.core == ["/tmp/SiteNote_001.pdf"]
|
||||
assert result.other == []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue