@@ -36,8 +36,8 @@ def test_create_issue_with_all_fields(self):
3636 issue = OperationOutcomeIssue (
3737 severity = "error" ,
3838 code = "forbidden" ,
39- diagnostics = "Access denied" ,
4039 details = coding_details ,
40+ diagnostics = "Access denied" ,
4141 location = ["parameters/nhs-number" ],
4242 )
4343
@@ -58,8 +58,8 @@ def test_create_issue_without_location(self):
5858 issue = OperationOutcomeIssue (
5959 severity = "warning" ,
6060 code = "processing" ,
61- diagnostics = "Some warning" ,
6261 details = {"coding" : []},
62+ diagnostics = "Some warning" ,
6363 )
6464
6565 # Then
@@ -71,8 +71,8 @@ def test_model_dump_includes_all_fields_when_location_present(self):
7171 issue = OperationOutcomeIssue (
7272 severity = "error" ,
7373 code = "value" ,
74- diagnostics = "Invalid value" ,
7574 details = {"coding" : []},
75+ diagnostics = "Invalid value" ,
7676 location = ["parameters/condition" ],
7777 )
7878
@@ -94,7 +94,7 @@ def test_model_dump_includes_all_fields_when_location_present(self):
9494 def test_model_dump_excludes_none_excludes_none_location (self ):
9595 """Test that model_dump(exclude_none=True) excludes location field when it's None."""
9696 # Given
97- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
97+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
9898
9999 # When
100100 result = issue .model_dump (exclude_none = True )
@@ -123,8 +123,8 @@ def test_validation_error_on_extra_field(self):
123123 OperationOutcomeIssue (
124124 severity = "error" ,
125125 code = "processing" ,
126- diagnostics = "Error" ,
127126 details = {},
127+ diagnostics = "Error" ,
128128 unexpected_field = "value" ,
129129 )
130130
@@ -137,7 +137,7 @@ class TestOperationOutcome:
137137 def test_create_operation_outcome_with_required_fields (self ):
138138 """Test creating an OperationOutcome with only required fields."""
139139 # Given
140- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
140+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
141141
142142 # When
143143 outcome = OperationOutcome (issue = [issue ])
@@ -155,7 +155,7 @@ def test_create_operation_outcome_with_required_fields(self):
155155 def test_create_operation_outcome_with_all_fields (self ):
156156 """Test creating an OperationOutcome with all fields."""
157157 # Given
158- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
158+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
159159 test_id = "test-id-123"
160160 test_meta = {"lastUpdated" : datetime .now (UTC )}
161161
@@ -171,7 +171,7 @@ def test_create_operation_outcome_with_all_fields(self):
171171 def test_resource_type_is_always_operation_outcome (self ):
172172 """Test that resourceType is always 'OperationOutcome' and cannot be changed."""
173173 # Given
174- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
174+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
175175 outcome = OperationOutcome (issue = [issue ])
176176
177177 # When, Then
@@ -186,8 +186,8 @@ def test_model_dump_with_all_fields(self):
186186 issue = OperationOutcomeIssue (
187187 severity = "error" ,
188188 code = "processing" ,
189- diagnostics = "Error message" ,
190189 details = {"coding" : []},
190+ diagnostics = "Error message" ,
191191 location = ["param" ],
192192 )
193193 outcome = OperationOutcome (issue = [issue ], id = "abc-123" , meta = {"version" : "1" })
@@ -209,7 +209,7 @@ def test_model_dump_with_all_fields(self):
209209 def test_model_dump_exclude_none_excludes_none_id (self ):
210210 """Test that model_dump(exclude_none=True) excludes id field when it's None."""
211211 # Given
212- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
212+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
213213 outcome = OperationOutcome (issue = [issue ])
214214
215215 # When
@@ -223,7 +223,7 @@ def test_model_dump_exclude_none_excludes_none_id(self):
223223 def test_model_dump_mode_json_with_datetime (self ):
224224 """Test that mode='json' serializes datetime objects to ISO strings."""
225225 # Given
226- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
226+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
227227 test_datetime = datetime (2024 , 1 , 15 , 10 , 30 , 45 , tzinfo = UTC )
228228 outcome = OperationOutcome (issue = [issue ], meta = {"lastUpdated" : test_datetime })
229229
@@ -237,7 +237,7 @@ def test_model_dump_mode_json_with_datetime(self):
237237 def test_model_dump_exclude_defaults_removes_empty_meta (self ):
238238 """Test that model_dump with exclude_defaults removes default empty meta."""
239239 # Given
240- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
240+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
241241 outcome = OperationOutcome (issue = [issue ])
242242
243243 # When
@@ -249,8 +249,8 @@ def test_model_dump_exclude_defaults_removes_empty_meta(self):
249249 def test_multiple_issues (self ):
250250 """Test OperationOutcome with multiple issues."""
251251 # Given
252- issue1 = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error 1" , details = {} )
253- issue2 = OperationOutcomeIssue (severity = "warning" , code = "value" , diagnostics = "Warning 1" , details = {} )
252+ issue1 = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error 1" )
253+ issue2 = OperationOutcomeIssue (severity = "warning" , code = "value" , details = {}, diagnostics = "Warning 1" )
254254
255255 # When
256256 outcome = OperationOutcome (issue = [issue1 , issue2 ])
@@ -273,7 +273,6 @@ def test_json_serialization_with_mode_json(self):
273273 issue = OperationOutcomeIssue (
274274 severity = "error" ,
275275 code = "forbidden" ,
276- diagnostics = "Access denied" ,
277276 details = {
278277 "coding" : [
279278 {
@@ -283,6 +282,7 @@ def test_json_serialization_with_mode_json(self):
283282 }
284283 ]
285284 },
285+ diagnostics = "Access denied" ,
286286 location = ["parameters/nhs-number" ],
287287 )
288288 outcome = OperationOutcome (issue = [issue ], id = "test-id" , meta = {"lastUpdated" : datetime .now (UTC )})
@@ -301,7 +301,6 @@ def test_fhir_compliant_structure(self):
301301 issue = OperationOutcomeIssue (
302302 severity = "error" ,
303303 code = "forbidden" ,
304- diagnostics = "You are not authorised" ,
305304 details = {
306305 "coding" : [
307306 {
@@ -311,6 +310,7 @@ def test_fhir_compliant_structure(self):
311310 }
312311 ]
313312 },
313+ diagnostics = "You are not authorised" ,
314314 location = ["parameters/nhs-number" ],
315315 )
316316 outcome = OperationOutcome (issue = [issue ], id = "123e4567-e89b-12d3-a456-426614174000" )
@@ -340,7 +340,7 @@ def test_fhir_compliant_structure(self):
340340 def test_model_validation_with_pydantic (self ):
341341 """Test that pydantic validation works correctly."""
342342 # Given, When
343- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
343+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
344344 outcome = OperationOutcome (issue = [issue ])
345345
346346 # Then
@@ -351,7 +351,7 @@ def test_model_validation_with_pydantic(self):
351351
352352 def test_validation_error_on_extra_field (self ):
353353 """Test that extra fields are rejected due to extra='forbid'."""
354- issue = OperationOutcomeIssue (severity = "error" , code = "processing" , diagnostics = "Error" , details = {} )
354+ issue = OperationOutcomeIssue (severity = "error" , code = "processing" , details = {}, diagnostics = "Error" )
355355
356356 with pytest .raises (ValidationError ) as exc_info :
357357 OperationOutcome (issue = [issue ], unexpected_field = "value" )
0 commit comments