mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Service persists mcs_certificate file_type when evidence_category is MCS cert 🟩
This commit is contained in:
parent
367f6f6cf9
commit
5fa6f32644
1 changed files with 27 additions and 0 deletions
|
|
@ -502,6 +502,33 @@ def test_run_persists_other_files_with_other_file_type() -> None:
|
|||
assert all_added[0].file_type == FileTypeEnum.OTHER.value
|
||||
|
||||
|
||||
def test_run_persists_mcs_cert_with_mcs_certificate_file_type() -> None:
|
||||
# Arrange
|
||||
mock_client = MagicMock(spec=PashubClient)
|
||||
mock_client.get_uprn_by_job_id.return_value = None
|
||||
mock_client.get_evidence_files_by_job_id.return_value = DownloadedFiles(
|
||||
core=[DownloadedFile("/tmp/MCS_cert.pdf", "MCS Compliance Certificate", datetime(2024, 1, 1))],
|
||||
other=[],
|
||||
)
|
||||
|
||||
fake_session = MagicMock()
|
||||
service = make_service(pashub_client=mock_client)
|
||||
|
||||
# Act
|
||||
with (
|
||||
patch("backend.pashub_fetcher.pashub_service.upload_file_to_s3"),
|
||||
patch("backend.pashub_fetcher.pashub_service.db_session") as mock_db,
|
||||
patch("backend.pashub_fetcher.pashub_service.os.remove"),
|
||||
):
|
||||
mock_db.return_value.__enter__.return_value = fake_session
|
||||
service.run(make_request(uprn="12345"))
|
||||
|
||||
# Assert
|
||||
fake_session.add_all.assert_called_once()
|
||||
added: list[Any] = fake_session.add_all.call_args[0][0]
|
||||
assert added[0].file_type == FileTypeEnum.MCS_CERTIFICATE.value
|
||||
|
||||
|
||||
def test_run_warns_and_continues_when_site_notes_parsing_fails() -> None:
|
||||
mock_client = MagicMock(spec=PashubClient)
|
||||
mock_client.get_uprn_by_job_id.return_value = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue