@@ -124,36 +124,39 @@ def test_install_and_call_flask_lambda_with_unknown_nhs_number(
124124 timeout = 10 ,
125125 )
126126
127- # Then
127+ decoded_body_bytes = base64 .b64decode (response .text )
128+ decoded_body_json = json .loads (decoded_body_bytes .decode ("utf-8" ))
129+
128130 assert_that (
129131 response ,
130132 is_response ()
131133 .with_status_code (HTTPStatus .NOT_FOUND )
132- .and_body (
133- is_json_that (
134+ .with_headers (has_entries ({"Content-Type" : "application/fhir+json" })),
135+ )
136+
137+ # Then
138+ assert_that (
139+ decoded_body_json ,
140+ has_entries (
141+ resourceType = equal_to ("OperationOutcome" ),
142+ issue = contains_exactly (
134143 has_entries (
135- resourceType = "OperationOutcome" ,
136- issue = contains_exactly (
137- has_entries (
138- severity = "error" ,
139- code = "processing" ,
140- diagnostics = f"NHS Number '{ nhs_number !s} ' was not "
141- f"recognised by the Eligibility Signposting API" ,
142- details = {
143- "coding" : [
144- {
145- "system" : "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1" ,
146- "code" : "REFERENCE_NOT_FOUND" ,
147- "display" : "The given NHS number was not found in our datasets. "
148- "This could be because the number is incorrect or "
149- "some other reason we cannot process that number." ,
150- }
151- ]
152- },
153- )
154- ),
144+ severity = "error" ,
145+ code = "processing" ,
146+ diagnostics = f"NHS Number '{ nhs_number !s} ' was not recognised by the Eligibility Signposting API" ,
147+ details = {
148+ "coding" : [
149+ {
150+ "system" : "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1" ,
151+ "code" : "REFERENCE_NOT_FOUND" ,
152+ "display" : "The given NHS number was not found in our datasets. "
153+ "This could be because the number is incorrect or "
154+ "some other reason we cannot process that number." ,
155+ }
156+ ]
157+ },
155158 )
156- )
159+ ),
157160 ),
158161 )
159162
@@ -292,6 +295,7 @@ def test_given_nhs_number_in_path_does_not_match_with_nhs_number_in_headers_resu
292295 response ,
293296 is_response ()
294297 .with_status_code (HTTPStatus .FORBIDDEN )
298+ .with_headers (has_entries ({"Content-Type" : "application/fhir+json" }))
295299 .and_body (
296300 is_json_that (
297301 has_entries (
@@ -338,6 +342,7 @@ def test_given_nhs_number_not_present_in_headers_results_in_error_response(
338342 response ,
339343 is_response ()
340344 .with_status_code (HTTPStatus .FORBIDDEN )
345+ .with_headers (has_entries ({"Content-Type" : "application/fhir+json" }))
341346 .and_body (
342347 is_json_that (
343348 has_entries (
0 commit comments