mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Merge pull request #1499 from Hestia-Homes/feature/abri-api-integration
Abri API: send request as XML
This commit is contained in:
commit
b6e49de628
2 changed files with 21 additions and 1 deletions
|
|
@ -142,7 +142,11 @@ class AbriClient:
|
|||
|
||||
def _post(self, envelope: bytes) -> bytes:
|
||||
try:
|
||||
response = self._session.post(self._config.endpoint_url, data=envelope)
|
||||
response = self._session.post(
|
||||
self._config.endpoint_url,
|
||||
data=envelope,
|
||||
headers={"Content-Type": "application/xml"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as error:
|
||||
raise AbriTransportError(str(error)) from error
|
||||
|
|
|
|||
|
|
@ -129,6 +129,22 @@ def test_log_job_sends_the_recorded_logjob_envelope_to_the_relay_endpoint(
|
|||
)
|
||||
|
||||
|
||||
def test_log_job_declares_the_xml_body_content_type_the_relay_requires(
|
||||
client: AbriClient, mock_session: MagicMock
|
||||
) -> None:
|
||||
# Arrange: the relay 400s an XML body posted without an XML content type.
|
||||
mock_session.post.return_value.content = _load_fixture(
|
||||
"abri_relay_logjob_success_response.xml"
|
||||
)
|
||||
|
||||
# Act
|
||||
client.log_job(_spec_example_request())
|
||||
|
||||
# Assert
|
||||
headers: dict[str, str] = mock_session.post.call_args.kwargs["headers"]
|
||||
assert headers["Content-Type"] == "application/xml"
|
||||
|
||||
|
||||
# --- abandon_job: rejection (canceljob's own error-details shape) ---
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue