diff --git a/domain/abri/models.py b/domain/abri/models.py index e0cd20c98..df726608b 100644 --- a/domain/abri/models.py +++ b/domain/abri/models.py @@ -49,7 +49,8 @@ class LogJobRequest: @dataclass(frozen=True) class JobLogged: job_no: str - logged_info: str + # Informational only (never read downstream); absent on some successes. + logged_info: Optional[str] @dataclass(frozen=True) diff --git a/domain/abri/phone_selection.py b/domain/abri/phone_selection.py index fe3588d5f..7e2ae98f0 100644 --- a/domain/abri/phone_selection.py +++ b/domain/abri/phone_selection.py @@ -22,9 +22,9 @@ class SelectedPhoneNumbers: secondary: Optional[str] -# TODO(#1474): confirm the priority ordering with Abri — this assumes the -# lowest numeric priority marks the preferred number, and that entries with -# a missing or non-numeric priority rank last (ties keep document order). +# Abri confirmed the lowest numeric priority marks the preferred number; +# entries with a missing or non-numeric priority rank last (ties keep +# document order). def _priority_sort_key(entry: PhoneEntry) -> Tuple[int, int]: """Sort key: lowest numeric priority first; unusable priorities last.""" try: diff --git a/infrastructure/abri/abri_client.py b/infrastructure/abri/abri_client.py index ebcd65f64..19054d200 100644 --- a/infrastructure/abri/abri_client.py +++ b/infrastructure/abri/abri_client.py @@ -174,14 +174,13 @@ class AbriClient: ) job_no = job_logged.get("job_no") - logged_info = job_logged.get("logged_info") - if job_no is None or logged_info is None: - raise AbriResponseParseError( - "Job_logged element missing job_no or logged_info" - ) + if job_no is None: + raise AbriResponseParseError("Job_logged element missing job_no") - return JobLogged(job_no=job_no, logged_info=logged_info) + # logged_info is purely informational and absent on some successes, so + # its presence is not required to accept the job as logged. + return JobLogged(job_no=job_no, logged_info=job_logged.get("logged_info")) @staticmethod def _parse_appointment_amended(root: ET.Element) -> AppointmentAmended: diff --git a/tests/infrastructure/abri/test_abri_client.py b/tests/infrastructure/abri/test_abri_client.py index 13bac577b..e891e4283 100644 --- a/tests/infrastructure/abri/test_abri_client.py +++ b/tests/infrastructure/abri/test_abri_client.py @@ -106,6 +106,22 @@ def test_log_job_returns_job_logged_with_openhousing_job_number( ) +def test_log_job_accepts_a_success_without_logged_info( + client: AbriClient, mock_session: MagicMock +) -> None: + # Arrange: logged_info is informational, so a success carrying only a + # job_no must still be accepted rather than fail a job that was logged. + mock_session.post.return_value.content = ( + b'' + ) + + # Act + result = client.log_job(_spec_example_request()) + + # Assert + assert result == JobLogged(job_no="AD1", logged_info=None) + + def test_log_job_sends_the_recorded_logjob_envelope_to_the_relay_endpoint( client: AbriClient, mock_session: MagicMock ) -> None: