@@ -130,8 +130,8 @@ def test_related_person__not_found(
130130 mock_generate_response_from_example .return_value = mocked_response = (
131131 Response (
132132 dumps ({"data" : "mocked" }),
133- status = status_code ,
134- content_type = "application/json"
133+ status = status_code ,
134+ content_type = "application/json"
135135 )
136136 )
137137 # Act
@@ -209,11 +209,6 @@ def test_questionnaire_response(
209209 "./api/examples/GET_Consent/multiple-relationships-include-performer-patient.yaml" ,
210210 200 ,
211211 ),
212- (
213- "performer:identifier=9000000025" ,
214- "./api/examples/GET_Consent/no-relationships.yaml" ,
215- 200 ,
216- ),
217212 (
218213 "performer:identifier=9000000010" ,
219214 "./api/examples/GET_Consent/single-consenting-adult-relationship.yaml" ,
@@ -236,7 +231,7 @@ def test_questionnaire_response(
236231 )
237232 ]
238233)
239- @patch (f"{ APP_FILE_PATH } .generate_response_from_example" )
234+ @patch (f"{ UTILS_FILE_PATH } .generate_response_from_example" )
240235def test_consent (
241236 mock_generate_response_from_example : MagicMock ,
242237 request_args : str ,
@@ -248,8 +243,8 @@ def test_consent(
248243 mock_generate_response_from_example .return_value = mocked_response = (
249244 Response (
250245 dumps ({"data" : "mocked" }),
251- status = status_code ,
252- content_type = "application/json"
246+ status = status_code ,
247+ content_type = "application/json"
253248 )
254249 )
255250 # Act
@@ -261,19 +256,46 @@ def test_consent(
261256
262257
263258@patch (f"{ APP_FILE_PATH } .generate_response_from_example" )
264- def test_consent__400_bad_request (
259+ def test_consent_no_relationships (
260+ mock_generate_response_from_example : MagicMock ,
261+ client : object
262+ ) -> None :
263+ """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+ )
270+ )
271+ # Act
272+ response = client .get (f"{ CONSENT_API_ENDPOINT } ?performer:identifier=9000000025" )
273+ # Assert
274+ mock_generate_response_from_example .assert_called_once_with ("./api/examples/GET_Consent/no-relationships.yaml" , 200 )
275+ assert response .status_code == 200
276+ assert response .json == json .loads (mocked_response .get_data (as_text = True ))
277+
278+
279+ @patch (f"{ APP_FILE_PATH } .generate_response_from_example" )
280+ def test_consent__404_bad_request (
265281 mock_generate_response_from_example : MagicMock ,
266282 client : object ,
267283) -> None :
268284 """Test Consent endpoint."""
269- mock_generate_response_from_example .return_value = {"data" : "mocked" }
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+ )
291+ )
270292 # Act
271293 client .get (
272294 f"{ CONSENT_API_ENDPOINT } ?performer:identifier=9000000999"
273295 )
274296 # Assert
275297 mock_generate_response_from_example .assert_called_once_with (
276- "./api/examples/errors/not-found.yaml"
298+ "./api/examples/errors/not-found.yaml" , 404
277299 )
278300
279301
0 commit comments