mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Abri amend_job amends an OpenHousing appointment and returns the echoed booking 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
6a7cc68c9a
commit
2cfed0c33d
4 changed files with 59 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from typing import Literal, NewType, Union
|
||||
from typing import Literal, NewType, Optional, Union
|
||||
|
||||
PlaceRef = NewType("PlaceRef", str)
|
||||
|
||||
|
|
@ -30,3 +30,21 @@ class AbriRequestRejected:
|
|||
|
||||
|
||||
LogJobResult = Union[JobLogged, AbriRequestRejected]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AmendJobRequest:
|
||||
job_no: str
|
||||
appointment_date: date
|
||||
appointment_time: SlotCode
|
||||
resource: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AppointmentAmended:
|
||||
job_no: str
|
||||
appointment_date: str
|
||||
appointment_time: str
|
||||
|
||||
|
||||
AmendJobResult = Union[AppointmentAmended, AbriRequestRejected]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import requests
|
|||
|
||||
from domain.abri.models import (
|
||||
AbriRequestRejected,
|
||||
AmendJobRequest,
|
||||
AmendJobResult,
|
||||
JobLogged,
|
||||
LogJobRequest,
|
||||
LogJobResult,
|
||||
|
|
@ -45,6 +47,9 @@ class AbriClient:
|
|||
|
||||
return self._parse_job_logged(outcome)
|
||||
|
||||
def amend_job(self, request: AmendJobRequest) -> AmendJobResult:
|
||||
raise NotImplementedError
|
||||
|
||||
def _exchange(
|
||||
self, request_type: str, parameters: List[Tuple[str, str]]
|
||||
) -> Union[ET.Element, AbriRequestRejected]:
|
||||
|
|
|
|||
3
tests/abri/abri_relay_amendoptiappt_success_response.xml
Normal file
3
tests/abri/abri_relay_amendoptiappt_success_response.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<Root>
|
||||
<AmendOptiAppt appointment_date="24/06/2026" appointment_time="PM" job_no="AC0439951" resource="NAULKH" success="Y" />
|
||||
</Root>
|
||||
|
|
@ -8,6 +8,8 @@ import requests
|
|||
|
||||
from domain.abri.models import (
|
||||
AbriRequestRejected,
|
||||
AmendJobRequest,
|
||||
AppointmentAmended,
|
||||
JobLogged,
|
||||
LogJobRequest,
|
||||
PlaceRef,
|
||||
|
|
@ -50,6 +52,14 @@ def _spec_example_request() -> LogJobRequest:
|
|||
)
|
||||
|
||||
|
||||
def _spec_example_amend_request() -> AmendJobRequest:
|
||||
return AmendJobRequest(
|
||||
job_no="AC0439951",
|
||||
appointment_date=date(2026, 6, 19),
|
||||
appointment_time="PM",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def mock_session() -> MagicMock:
|
||||
return MagicMock()
|
||||
|
|
@ -192,3 +202,25 @@ def test_log_job_raises_retriable_parse_error_on_an_unexpectedly_shaped_response
|
|||
# Act / Assert
|
||||
with pytest.raises(AbriResponseParseError):
|
||||
client.log_job(_spec_example_request())
|
||||
|
||||
|
||||
# --- amend_job: success ---
|
||||
|
||||
|
||||
def test_amend_job_returns_appointment_amended_echoing_the_response_attributes(
|
||||
client: AbriClient, mock_session: MagicMock
|
||||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _load_fixture(
|
||||
"abri_relay_amendoptiappt_success_response.xml"
|
||||
)
|
||||
|
||||
# Act
|
||||
result = client.amend_job(_spec_example_amend_request())
|
||||
|
||||
# Assert
|
||||
assert result == AppointmentAmended(
|
||||
job_no="AC0439951",
|
||||
appointment_date="24/06/2026",
|
||||
appointment_time="PM",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue