@@ -169,7 +169,7 @@ def test_get_survey_status_error_handled(self):
169
169
with self .assertRaises (CmixError ):
170
170
self .cmix_api .get_survey_status (self .survey_id )
171
171
172
- def test_get_survey_sources (self ):
172
+ def test_get_survey_locales (self ):
173
173
self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
174
174
175
175
# success case
@@ -178,7 +178,31 @@ def test_get_survey_sources(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
+ self .cmix_api .get_survey_locales (self .survey_id )
182
+
183
+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
184
+ surveys_url = '{}/surveys/{}/locales' .format (base_url , self .survey_id )
185
+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
186
+
187
+ # error case (survey not found)
188
+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
189
+ mock_get = mock .Mock ()
190
+ mock_get .status_code = 404
191
+ mock_get .json .return_value = {}
192
+ mock_request .get .return_value = mock_get
181
193
194
+ with self .assertRaises (CmixError ):
195
+ self .cmix_api .get_survey_locales (self .survey_id )
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
182
206
self .cmix_api .get_survey_sources (self .survey_id )
183
207
184
208
base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
0 commit comments