1010 INTERNAL_SERVER_ERROR_EXAMPLE ,
1111)
1212
13+ SANDBOX_API_URL = "https://sandbox.api.service.nhs.uk/validated-relationships"
1314QUESTIONNAIRE_RESPONSE_API_ENDPOINT = "/FHIR/R4/QuestionnaireResponse"
1415
1516
1617@pytest .mark .parametrize (
17- ("nhs_num" , "response_file_name" , "status_code" ),
18+ ("nhs_num" , "response_file_name" , "status_code" , "id" ),
1819 [
1920 (
2021 "9000000009" ,
2122 POST_QUESTIONNAIRE_RESPONSE__SUCCESS ,
2223 200 ,
24+ "156e1560-e532-4e2a-85ad-5aeff03dc43e" ,
2325 ),
2426 (
2527 "9000000017" ,
2628 POST_QUESTIONNAIRE_RESPONSE__SUCCESS ,
2729 200 ,
30+ "156e1560-e532-4e2a-85ad-5aeff03dc43e" ,
2831 ),
2932 (
3033 "9000000049" ,
4245def test_post_questionnaire_response (
4346 mock_generate_response_from_example : MagicMock ,
4447 nhs_num : str ,
48+ id : str ,
4549 response_file_name : str ,
4650 status_code : int ,
4751 client : object ,
@@ -57,6 +61,15 @@ def test_post_questionnaire_response(
5761 # Act
5862 response = client .post (QUESTIONNAIRE_RESPONSE_API_ENDPOINT , json = json )
5963 # Assert
60- mock_generate_response_from_example .assert_called_once_with (response_file_name , status_code )
64+ if id is not None :
65+ mock_generate_response_from_example .assert_called_once_with (
66+ response_file_name ,
67+ status_code ,
68+ headers = {
69+ "location" : f"{ SANDBOX_API_URL } { QUESTIONNAIRE_RESPONSE_API_ENDPOINT } ?ID={ id } "
70+ },
71+ )
72+ else :
73+ mock_generate_response_from_example .assert_called_once_with (response_file_name , status_code )
6174 assert response .status_code == status_code
6275 assert response .json == loads (mocked_response .get_data (as_text = True ))
0 commit comments