Skip to content

Commit 41000c3

Browse files
NRL-1215 Fix linting issues
1 parent 05573ea commit 41000c3

File tree

4 files changed

+74
-66
lines changed

4 files changed

+74
-66
lines changed

layer/nrlf/core/json_duplicate_checker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def traverse_array(self, items: JsonArray, path: list[str]) -> None:
8585
if serialized_item in seen_elements:
8686
element = f"{array_path}[{idx}]"
8787
duplicate_path = ".".join(base_path + [element])
88-
self.duplicate_keys_and_paths.setdefault(element, []).append(duplicate_path)
88+
self.duplicate_keys_and_paths.setdefault(element, []).append(
89+
duplicate_path
90+
)
8991
print(f"Found duplicate array element at path: {duplicate_path}")
9092
else:
9193
seen_elements.add(serialized_item)

layer/nrlf/core/tests/test_json_duplicate_checker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,9 @@ def test_deeply_nested_object_with_deeply_nested_array_duplicate(self):
375375
duplicates, paths = check_duplicate_keys(json_content)
376376
self.assertEqual(duplicates, ["array[1]"])
377377
# duplicate root here needs fixing in traverse_array loop
378-
self.assertEqual(paths, ["root.root.level1.level2.level3.level4.level5.level6.level7.level8.level9.level10.array[1]"])
378+
self.assertEqual(
379+
paths,
380+
[
381+
"root.root.level1.level2.level3.level4.level5.level6.level7.level8.level9.level10.array[1]"
382+
],
383+
)

tests/features/producer/updateDocumentReference-duplicateField.feature

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,34 @@ Feature: Producer - updateDocumentReference - Duplicate Field Scenarios
1818
| author | TSTCUS |
1919
When producer 'TSTCUS' requests update of a DocumentReference with pointerId 'TSTCUS-updateDuplicateTest-1234' but replacing 'content':
2020
"""
21-
[
22-
{
23-
"attachment": {
24-
"contentType": "application/pdf",
25-
"url": "https://example.org/my-doc.pdf",
26-
"url": "https://example.org/duplicate-url.pdf"
27-
},
28-
"format": {
29-
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
30-
"code": "urn:nhs-ic:unstructured",
31-
"display": "Unstructured Document"
32-
},
33-
"extension": [
34-
{
35-
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
36-
"valueCodeableConcept": {
37-
"coding": [
38-
{
39-
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
40-
"code": "static",
41-
"display": "Static"
42-
}
43-
]
44-
}
21+
[
22+
{
23+
"attachment": {
24+
"contentType": "application/pdf",
25+
"url": "https://example.org/my-doc.pdf",
26+
"url": "https://example.org/duplicate-url.pdf"
27+
},
28+
"format": {
29+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
30+
"code": "urn:nhs-ic:unstructured",
31+
"display": "Unstructured Document"
32+
},
33+
"extension": [
34+
{
35+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
36+
"valueCodeableConcept": {
37+
"coding": [
38+
{
39+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
40+
"code": "static",
41+
"display": "Static"
42+
}
43+
]
4544
}
46-
]
47-
}
48-
]
45+
}
46+
]
47+
}
48+
]
4949
"""
5050
Then the response status code is 400
5151
And the response is an OperationOutcome with 1 issue
@@ -88,42 +88,42 @@ Feature: Producer - updateDocumentReference - Duplicate Field Scenarios
8888
| author | TSTCUS |
8989
When producer 'TSTCUS' requests update of a DocumentReference with pointerId 'TSTCUS-updateDuplicateTest-1235' but replacing 'content':
9090
"""
91-
[
92-
{
93-
"attachment": {
94-
"contentType": "application/pdf",
95-
"url": "https://example.org/my-doc.pdf"
96-
},
97-
"attachment": {
98-
"contentType": "text/html",
99-
"url": "https://example.org/contact-details.html"
100-
},
101-
"format": {
102-
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
103-
"code": "urn:nhs-ic:unstructured",
104-
"display": "Unstructured Document"
105-
},
106-
"format": {
107-
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
108-
"code": "urn:nhs-ic:record-contact",
109-
"display": "Contact details (HTTP Unsecured)"
110-
},
111-
"extension": [
112-
{
113-
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
114-
"valueCodeableConcept": {
115-
"coding": [
116-
{
117-
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
118-
"code": "static",
119-
"display": "Static"
120-
}
121-
]
122-
}
91+
[
92+
{
93+
"attachment": {
94+
"contentType": "application/pdf",
95+
"url": "https://example.org/my-doc.pdf"
96+
},
97+
"attachment": {
98+
"contentType": "text/html",
99+
"url": "https://example.org/contact-details.html"
100+
},
101+
"format": {
102+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
103+
"code": "urn:nhs-ic:unstructured",
104+
"display": "Unstructured Document"
105+
},
106+
"format": {
107+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
108+
"code": "urn:nhs-ic:record-contact",
109+
"display": "Contact details (HTTP Unsecured)"
110+
},
111+
"extension": [
112+
{
113+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
114+
"valueCodeableConcept": {
115+
"coding": [
116+
{
117+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
118+
"code": "static",
119+
"display": "Static"
120+
}
121+
]
123122
}
124-
]
125-
}
126-
]
123+
}
124+
]
125+
}
126+
]
127127
"""
128128
Then the response status code is 400
129129
And the response is an OperationOutcome with 1 issue

tests/features/steps/2_request.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,18 @@ def create_post_body_step(context: Context, section: str):
133133
def upsert_post_body_step(context: Context, section: str, pointer_id: str):
134134
_create_or_upsert_body_step(context, "upsert_text", section, pointer_id)
135135

136+
136137
@when(
137138
"producer 'TSTCUS' requests update of a DocumentReference with pointerId '{pointer_id}' but replacing '{section}'"
138139
)
139140
def update_post_body_step(context: Context, section: str, pointer_id: str):
140-
""" This can only update top level fields """
141+
"""This can only update top level fields"""
141142
consumer_client = consumer_client_from_context(context, "TSTCUS")
142143
context.response = consumer_client.read(pointer_id)
143144

144145
if context.response.status_code != 200:
145146
raise ValueError(f"Failed to read existing pointer: {context.response.text}")
146-
147+
147148
doc_ref = context.response.json()
148149
doc_ref[section] = "placeholder"
149150
doc_ref_text = json.dumps(doc_ref)

0 commit comments

Comments
 (0)