Skip to content

Commit cbae7ca

Browse files
committed
Merge branch 'feature/PI-534-errors_without_fhir' into release/2024-10-14
2 parents 5f1fc4b + 5acb3fc commit cbae7ca

28 files changed

+506
-1111
lines changed

src/api/createCpmProduct/tests/test_index.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,10 @@ def test_index_no_such_product_team(version):
146146
)
147147
expected_result = json.dumps(
148148
{
149-
"resourceType": "OperationOutcome",
150-
"id": app_logger.service_name,
151-
"meta": {
152-
"profile": [
153-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
154-
]
155-
},
156-
"issue": [
149+
"errors": [
157150
{
158-
"severity": "error",
159-
"code": "processing",
160-
"details": {
161-
"coding": [
162-
{
163-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
164-
"code": "RESOURCE_NOT_FOUND",
165-
"display": "Resource not found",
166-
}
167-
]
168-
},
169-
"diagnostics": "Could not find ProductTeam for key ('FOOBAR')",
151+
"code": "RESOURCE_NOT_FOUND",
152+
"message": "Could not find ProductTeam for key ('FOOBAR')",
170153
}
171154
],
172155
}

src/api/createDevice/tests/test_index.py

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -112,73 +112,22 @@ def test_index_bad_payload(version):
112112

113113
expected_body = json.dumps(
114114
{
115-
"resourceType": "OperationOutcome",
116-
"id": app_logger.service_name,
117-
"meta": {
118-
"profile": [
119-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
120-
]
121-
},
122-
"issue": [
115+
"errors": [
123116
{
124-
"severity": "error",
125-
"code": "processing",
126-
"details": {
127-
"coding": [
128-
{
129-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
130-
"code": "MISSING_VALUE",
131-
"display": "Missing value",
132-
}
133-
]
134-
},
135-
"diagnostics": "field required",
136-
"expression": ["Device.resourceType"],
117+
"code": "MISSING_VALUE",
118+
"message": "Device.resourceType: field required",
137119
},
138120
{
139-
"severity": "error",
140-
"code": "processing",
141-
"details": {
142-
"coding": [
143-
{
144-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
145-
"code": "MISSING_VALUE",
146-
"display": "Missing value",
147-
}
148-
]
149-
},
150-
"diagnostics": "field required",
151-
"expression": ["Device.deviceName"],
121+
"code": "MISSING_VALUE",
122+
"message": "Device.deviceName: field required",
152123
},
153124
{
154-
"severity": "error",
155-
"code": "processing",
156-
"details": {
157-
"coding": [
158-
{
159-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
160-
"code": "MISSING_VALUE",
161-
"display": "Missing value",
162-
}
163-
]
164-
},
165-
"diagnostics": "field required",
166-
"expression": ["Device.definition"],
125+
"code": "MISSING_VALUE",
126+
"message": "Device.definition: field required",
167127
},
168128
{
169-
"severity": "error",
170-
"code": "processing",
171-
"details": {
172-
"coding": [
173-
{
174-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
175-
"code": "MISSING_VALUE",
176-
"display": "Missing value",
177-
}
178-
]
179-
},
180-
"diagnostics": "field required",
181-
"expression": ["Device.owner"],
129+
"code": "MISSING_VALUE",
130+
"message": "Device.owner: field required",
182131
},
183132
],
184133
}

src/api/createProductTeam/tests/test_index.py

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -98,73 +98,22 @@ def test_index_bad_payload(version):
9898

9999
expected_body = json.dumps(
100100
{
101-
"resourceType": "OperationOutcome",
102-
"id": app_logger.service_name,
103-
"meta": {
104-
"profile": [
105-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
106-
]
107-
},
108-
"issue": [
101+
"errors": [
109102
{
110-
"severity": "error",
111-
"code": "processing",
112-
"details": {
113-
"coding": [
114-
{
115-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
116-
"code": "MISSING_VALUE",
117-
"display": "Missing value",
118-
}
119-
]
120-
},
121-
"diagnostics": "field required",
122-
"expression": ["Organization.resourceType"],
103+
"code": "MISSING_VALUE",
104+
"message": "Organization.resourceType: field required",
123105
},
124106
{
125-
"severity": "error",
126-
"code": "processing",
127-
"details": {
128-
"coding": [
129-
{
130-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
131-
"code": "MISSING_VALUE",
132-
"display": "Missing value",
133-
}
134-
]
135-
},
136-
"diagnostics": "field required",
137-
"expression": ["Organization.identifier"],
107+
"code": "MISSING_VALUE",
108+
"message": "Organization.identifier: field required",
138109
},
139110
{
140-
"severity": "error",
141-
"code": "processing",
142-
"details": {
143-
"coding": [
144-
{
145-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
146-
"code": "MISSING_VALUE",
147-
"display": "Missing value",
148-
}
149-
]
150-
},
151-
"diagnostics": "field required",
152-
"expression": ["Organization.name"],
111+
"code": "MISSING_VALUE",
112+
"message": "Organization.name: field required",
153113
},
154114
{
155-
"severity": "error",
156-
"code": "processing",
157-
"details": {
158-
"coding": [
159-
{
160-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
161-
"code": "MISSING_VALUE",
162-
"display": "Missing value",
163-
}
164-
]
165-
},
166-
"diagnostics": "field required",
167-
"expression": ["Organization.partOf"],
115+
"code": "MISSING_VALUE",
116+
"message": "Organization.partOf: field required",
168117
},
169118
],
170119
}

src/api/readCpmProduct/tests/test_index.py

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from domain.repository.cpm_product_repository.v3 import CpmProductRepository
88
from domain.repository.product_team_repository.v2 import ProductTeamRepository
99
from event.json import json_loads
10-
from nhs_context_logging import app_logger
1110

1211
from test_helpers.dynamodb import mock_table
1312
from test_helpers.response_assertions import _response_assertions
@@ -126,27 +125,10 @@ def test_index_no_such_cpm_product(version):
126125

127126
expected_result = json.dumps(
128127
{
129-
"resourceType": "OperationOutcome",
130-
"id": app_logger.service_name,
131-
"meta": {
132-
"profile": [
133-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
134-
]
135-
},
136-
"issue": [
128+
"errors": [
137129
{
138-
"severity": "error",
139-
"code": "processing",
140-
"details": {
141-
"coding": [
142-
{
143-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
144-
"code": "RESOURCE_NOT_FOUND",
145-
"display": "Resource not found",
146-
}
147-
]
148-
},
149-
"diagnostics": f"Could not find CpmProduct for key ('{PRODUCT_TEAM_ID}', '{PRODUCT_ID}')",
130+
"code": "RESOURCE_NOT_FOUND",
131+
"message": f"Could not find CpmProduct for key ('{PRODUCT_TEAM_ID}', '{PRODUCT_ID}')",
150132
}
151133
],
152134
}
@@ -207,27 +189,10 @@ def test_index_no_such_product_team(version):
207189

208190
expected_result = json.dumps(
209191
{
210-
"resourceType": "OperationOutcome",
211-
"id": app_logger.service_name,
212-
"meta": {
213-
"profile": [
214-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
215-
]
216-
},
217-
"issue": [
192+
"errors": [
218193
{
219-
"severity": "error",
220-
"code": "processing",
221-
"details": {
222-
"coding": [
223-
{
224-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
225-
"code": "RESOURCE_NOT_FOUND",
226-
"display": "Resource not found",
227-
}
228-
]
229-
},
230-
"diagnostics": f"Could not find ProductTeam for key ('{PRODUCT_TEAM_ID}')",
194+
"code": "RESOURCE_NOT_FOUND",
195+
"message": f"Could not find ProductTeam for key ('{PRODUCT_TEAM_ID}')",
231196
}
232197
],
233198
}

src/api/readDevice/tests/test_index.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from domain.core.device_key import DeviceKeyType
77
from domain.core.root import Root
88
from domain.repository.device_repository import DeviceRepository
9-
from nhs_context_logging import app_logger
109

1110
from test_helpers.dynamodb import mock_table
1211
from test_helpers.response_assertions import _response_assertions
@@ -115,27 +114,10 @@ def test_index_no_such_device(version):
115114

116115
expected_result = json.dumps(
117116
{
118-
"resourceType": "OperationOutcome",
119-
"id": app_logger.service_name,
120-
"meta": {
121-
"profile": [
122-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
123-
]
124-
},
125-
"issue": [
117+
"errors": [
126118
{
127-
"severity": "error",
128-
"code": "processing",
129-
"details": {
130-
"coding": [
131-
{
132-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
133-
"code": "RESOURCE_NOT_FOUND",
134-
"display": "Resource not found",
135-
}
136-
]
137-
},
138-
"diagnostics": "Could not find Device for key ('123')",
119+
"code": "RESOURCE_NOT_FOUND",
120+
"message": "Could not find Device for key ('123')",
139121
}
140122
],
141123
}

src/api/readProductTeam/tests/test_index.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
from domain.core.root import Root
77
from domain.repository.product_team_repository.v1 import ProductTeamRepository
8-
from nhs_context_logging import app_logger
98

109
from test_helpers.dynamodb import mock_table
1110
from test_helpers.response_assertions import _response_assertions
@@ -121,27 +120,10 @@ def test_index_no_such_product_team(version):
121120

122121
expected_result = json.dumps(
123122
{
124-
"resourceType": "OperationOutcome",
125-
"id": app_logger.service_name,
126-
"meta": {
127-
"profile": [
128-
"https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome"
129-
]
130-
},
131-
"issue": [
123+
"errors": [
132124
{
133-
"severity": "error",
134-
"code": "processing",
135-
"details": {
136-
"coding": [
137-
{
138-
"system": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-OperationOutcome",
139-
"code": "RESOURCE_NOT_FOUND",
140-
"display": "Resource not found",
141-
}
142-
]
143-
},
144-
"diagnostics": "Could not find ProductTeam for key ('123')",
125+
"code": "RESOURCE_NOT_FOUND",
126+
"message": "Could not find ProductTeam for key ('123')",
145127
}
146128
],
147129
}

src/api/searchSdsEndpoint/tests/test_index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,19 @@ def test_multiple_returned(params, devices):
254254
"nhs_id_code": "RTX",
255255
},
256256
"VALIDATION_ERROR",
257-
"At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
257+
"SearchSDSEndpointQueryParams.__root__: At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
258258
400,
259259
),
260260
(
261261
{"nhs_mhs_svc_ia": "urn:nhs:names:services:ebs:PRSC_IN040000UK08"},
262262
"VALIDATION_ERROR",
263-
"At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
263+
"SearchSDSEndpointQueryParams.__root__: At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
264264
400,
265265
),
266266
(
267267
{"nhs_mhs_party_key": "D81631-827817"},
268268
"VALIDATION_ERROR",
269-
"At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
269+
"SearchSDSEndpointQueryParams.__root__: At least 2 query parameters should be provided of type, nhs_id_code, nhs_mhs_svc_ia and nhs_mhs_party_key",
270270
400,
271271
),
272272
(
@@ -276,7 +276,7 @@ def test_multiple_returned(params, devices):
276276
"foo": "bar",
277277
},
278278
"VALIDATION_ERROR",
279-
"extra fields not permitted",
279+
"SearchSDSEndpointQueryParams.foo: extra fields not permitted",
280280
400,
281281
),
282282
],
@@ -303,8 +303,8 @@ def test_filter_errors(params, error_code, error_msg, status_code):
303303
assert result["statusCode"] == status_code
304304
result_body = json_loads(result["body"])
305305

306-
assert result_body["issue"][0]["details"]["coding"][0]["code"] == error_code
307-
assert result_body["issue"][0]["diagnostics"] == error_msg
306+
assert result_body["errors"][0]["code"] == error_code
307+
assert result_body["errors"][0]["message"] == error_msg
308308

309309

310310
@pytest.mark.integration

0 commit comments

Comments
 (0)