@@ -116,6 +116,32 @@ def test_create_export_archive_errors_handled(self):
116116 with self .assertRaises (CmixError ):
117117 self .cmix_api .create_export_archive (self .survey_id , 'XLSX_READABLE' )
118118
119+ def test_get_survey_data_layouts (self ):
120+ self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
121+
122+ # success case
123+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
124+ mock_get = mock .Mock ()
125+ mock_get .status_code = 200
126+ mock_get .json .return_value = {}
127+ mock_request .get .return_value = mock_get
128+
129+ self .cmix_api .get_survey_data_layouts (self .survey_id )
130+
131+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
132+ surveys_url = '{}/surveys/{}/data-layouts' .format (base_url , self .survey_id )
133+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
134+
135+ # error case (survey not found)
136+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
137+ mock_get = mock .Mock ()
138+ mock_get .status_code = 404
139+ mock_get .json .return_value = {}
140+ mock_request .get .return_value = mock_get
141+
142+ with self .assertRaises (CmixError ):
143+ self .cmix_api .get_survey_data_layouts (self .survey_id )
144+
119145 def test_get_survey_status (self ):
120146 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
121147
@@ -169,6 +195,31 @@ def test_get_survey_sections(self):
169195 with self .assertRaises (CmixError ):
170196 self .cmix_api .get_survey_sections (self .survey_id )
171197
198+ def test_get_survey_sources (self ):
199+ self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
200+
201+ # success case
202+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
203+ mock_get = mock .Mock ()
204+ mock_get .status_code = 200
205+ mock_get .json .return_value = {}
206+ mock_request .get .return_value = mock_get
207+ self .cmix_api .get_survey_sources (self .survey_id )
208+
209+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
210+ surveys_url = '{}/surveys/{}/sources' .format (base_url , self .survey_id )
211+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
212+
213+ # error case (survey not found)
214+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
215+ mock_get = mock .Mock ()
216+ mock_get .status_code = 404
217+ mock_get .json .return_value = {}
218+ mock_request .get .return_value = mock_get
219+
220+ with self .assertRaises (CmixError ):
221+ self .cmix_api .get_survey_sources (self .survey_id )
222+
172223 def test_get_survey_test_url (self ):
173224 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
174225 correct_test_link = '{}/#/?cmixSvy={}&cmixTest={}' .format (
@@ -296,3 +347,29 @@ def test_add_extra_url_params(self):
296347 extra_params_formatted = '&{}&{}' .format (extra_params [0 ], extra_params [1 ])
297348 expected = '{}{}' .format (url , extra_params_formatted )
298349 self .assertEqual (result , expected )
350+
351+ def test_get_survey_simulations (self ):
352+ self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
353+
354+ # success case
355+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
356+ mock_get = mock .Mock ()
357+ mock_get .status_code = 200
358+ mock_get .json .return_value = {}
359+ mock_request .get .return_value = mock_get
360+
361+ self .cmix_api .get_survey_simulations (self .survey_id )
362+
363+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
364+ surveys_url = '{}/surveys/{}/simulations' .format (base_url , self .survey_id )
365+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
366+
367+ # error case (survey not found)
368+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
369+ mock_get = mock .Mock ()
370+ mock_get .status_code = 404
371+ mock_get .json .return_value = {}
372+ mock_request .get .return_value = mock_get
373+
374+ with self .assertRaises (CmixError ):
375+ self .cmix_api .get_survey_simulations (self .survey_id )
0 commit comments