@@ -178,7 +178,6 @@ def test_get_survey_locales(self):
178
178
mock_get .status_code = 200
179
179
mock_get .json .return_value = {}
180
180
mock_request .get .return_value = mock_get
181
-
182
181
self .cmix_api .get_survey_locales (self .survey_id )
183
182
184
183
base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
@@ -195,6 +194,31 @@ def test_get_survey_locales(self):
195
194
with self .assertRaises (CmixError ):
196
195
self .cmix_api .get_survey_locales (self .survey_id )
197
196
197
+ def test_get_survey_sources (self ):
198
+ self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
199
+
200
+ # success case
201
+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
202
+ mock_get = mock .Mock ()
203
+ mock_get .status_code = 200
204
+ mock_get .json .return_value = {}
205
+ mock_request .get .return_value = mock_get
206
+ self .cmix_api .get_survey_sources (self .survey_id )
207
+
208
+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
209
+ surveys_url = '{}/surveys/{}/sources' .format (base_url , self .survey_id )
210
+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
211
+
212
+ # error case (survey not found)
213
+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
214
+ mock_get = mock .Mock ()
215
+ mock_get .status_code = 404
216
+ mock_get .json .return_value = {}
217
+ mock_request .get .return_value = mock_get
218
+
219
+ with self .assertRaises (CmixError ):
220
+ self .cmix_api .get_survey_sources (self .survey_id )
221
+
198
222
def test_get_survey_test_url (self ):
199
223
self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
200
224
correct_test_link = '{}/#/?cmixSvy={}&cmixTest={}' .format (
0 commit comments