Skip to content

Commit eee3756

Browse files
committed
refactor: updated formatting
1 parent f39c79e commit eee3756

File tree

2 files changed

+30
-45
lines changed

2 files changed

+30
-45
lines changed

sandbox/api/tests/test_app.py

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_related_person(
114114
"identifier=9000000017&patient:identifier=9000000041",
115115
"./api/examples/errors/not-found.yaml",
116116
404,
117-
)
117+
),
118118
],
119119
)
120120
@patch(f"{UTILS_FILE_PATH}.generate_response_from_example")
@@ -123,21 +123,19 @@ def test_related_person__not_found(
123123
request_args: str,
124124
response_file_name: str,
125125
status_code: int,
126-
client: object
126+
client: object,
127127
) -> None:
128128
"""Test related_persons endpoint."""
129129
# Arrange
130-
mock_generate_response_from_example.return_value = mocked_response = (
131-
Response(
132-
dumps({"data": "mocked"}),
133-
status = status_code,
134-
content_type = "application/json"
135-
)
130+
mock_generate_response_from_example.return_value = mocked_response = Response(
131+
dumps({"data": "mocked"}), status=status_code, content_type="application/json"
136132
)
137133
# Act
138134
response = client.get(f"{RELATED_PERSON_API_ENDPOINT}?{request_args}")
139135
# Assert
140-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
136+
mock_generate_response_from_example.assert_called_once_with(
137+
response_file_name, status_code
138+
)
141139
assert response.status_code == status_code
142140
assert response.json == json.loads(mocked_response.get_data(as_text=True))
143141

@@ -227,51 +225,46 @@ def test_questionnaire_response(
227225
(
228226
"performer:identifier=9000000019&_include=Consent:performer,Consent:patient",
229227
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
230-
200
231-
)
232-
]
228+
200,
229+
),
230+
],
233231
)
234232
@patch(f"{UTILS_FILE_PATH}.generate_response_from_example")
235233
def test_consent(
236234
mock_generate_response_from_example: MagicMock,
237235
request_args: str,
238236
response_file_name: str,
239237
status_code: int,
240-
client: object
238+
client: object,
241239
) -> None:
242240
"""Test Consent endpoint."""
243-
mock_generate_response_from_example.return_value = mocked_response = (
244-
Response(
245-
dumps({"data": "mocked"}),
246-
status = status_code,
247-
content_type = "application/json"
248-
)
241+
mock_generate_response_from_example.return_value = mocked_response = Response(
242+
dumps({"data": "mocked"}), status=status_code, content_type="application/json"
249243
)
250244
# Act
251245
response = client.get(f"{CONSENT_API_ENDPOINT}?{request_args}")
252246
# Assert
253-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
247+
mock_generate_response_from_example.assert_called_once_with(
248+
response_file_name, status_code
249+
)
254250
assert response.status_code == status_code
255251
assert response.json == json.loads(mocked_response.get_data(as_text=True))
256252

257253

258254
@patch(f"{APP_FILE_PATH}.generate_response_from_example")
259255
def test_consent_no_relationships(
260-
mock_generate_response_from_example: MagicMock,
261-
client: object
256+
mock_generate_response_from_example: MagicMock, client: object
262257
) -> None:
263258
"""Test Consent endpoint."""
264-
mock_generate_response_from_example.return_value = mocked_response = (
265-
Response(
266-
dumps({"data": "mocked"}),
267-
status = 200,
268-
content_type = "application/json"
269-
)
259+
mock_generate_response_from_example.return_value = mocked_response = Response(
260+
dumps({"data": "mocked"}), status=200, content_type="application/json"
270261
)
271262
# Act
272263
response = client.get(f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000025")
273264
# Assert
274-
mock_generate_response_from_example.assert_called_once_with("./api/examples/GET_Consent/no-relationships.yaml", 200)
265+
mock_generate_response_from_example.assert_called_once_with(
266+
"./api/examples/GET_Consent/no-relationships.yaml", 200
267+
)
275268
assert response.status_code == 200
276269
assert response.json == json.loads(mocked_response.get_data(as_text=True))
277270

@@ -282,17 +275,11 @@ def test_consent__404_bad_request(
282275
client: object,
283276
) -> None:
284277
"""Test Consent endpoint."""
285-
mock_generate_response_from_example.return_value = mocked_response = (
286-
Response(
287-
dumps({"data": "mocked"}),
288-
status = 404,
289-
content_type = "application/json"
290-
)
278+
mock_generate_response_from_example.return_value = mocked_response = Response(
279+
dumps({"data": "mocked"}), status=404, content_type="application/json"
291280
)
292281
# Act
293-
client.get(
294-
f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000999"
295-
)
282+
client.get(f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000999")
296283
# Assert
297284
mock_generate_response_from_example.assert_called_once_with(
298285
"./api/examples/errors/not-found.yaml", 404

sandbox/api/tests/test_utils.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ def test_check_for_errors(
5252
status_code: int,
5353
client: object,
5454
) -> None:
55-
mock_generate_response_from_example.return_value = mocked_response = (
56-
Response(
57-
dumps({"data": "mocked"}),
58-
status=status_code,
59-
content_type="application/json"
60-
)
55+
mock_generate_response_from_example.return_value = mocked_response = Response(
56+
dumps({"data": "mocked"}), status=status_code, content_type="application/json"
6157
)
6258
# Act
6359
response = client.get(f"{RELATED_PERSON_API_ENDPOINT}?{request_args}")
6460
# Assert
65-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
61+
mock_generate_response_from_example.assert_called_once_with(
62+
response_file_name, status_code
63+
)
6664
assert response.status_code == status_code

0 commit comments

Comments
 (0)