@@ -178,7 +178,18 @@ def test_get_survey_sections(self):
178178 mock_get .status_code = 200
179179 mock_get .json .return_value = {}
180180 mock_request .get .return_value = mock_get
181+ self .cmix_api .get_survey_locales (self .survey_id )
181182
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
182193 self .cmix_api .get_survey_sections (self .survey_id )
183194
184195 base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
@@ -195,6 +206,31 @@ def test_get_survey_sections(self):
195206 with self .assertRaises (CmixError ):
196207 self .cmix_api .get_survey_sections (self .survey_id )
197208
209+ def test_get_survey_locales (self ):
210+ self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
211+
212+ # success case
213+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
214+ mock_get = mock .Mock ()
215+ mock_get .status_code = 200
216+ mock_get .json .return_value = {}
217+ mock_request .get .return_value = mock_get
218+ self .cmix_api .get_survey_locales (self .survey_id )
219+
220+ base_url = CMIX_SERVICES ['survey' ]['BASE_URL' ]
221+ surveys_url = '{}/surveys/{}/locales' .format (base_url , self .survey_id )
222+ mock_request .get .assert_any_call (surveys_url , headers = self .cmix_api ._authentication_headers )
223+
224+ # error case (survey not found)
225+ with mock .patch ('CmixAPIClient.api.requests' ) as mock_request :
226+ mock_get = mock .Mock ()
227+ mock_get .status_code = 404
228+ mock_get .json .return_value = {}
229+ mock_request .get .return_value = mock_get
230+
231+ with self .assertRaises (CmixError ):
232+ self .cmix_api .get_survey_locales (self .survey_id )
233+
198234 def test_get_survey_sources (self ):
199235 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
200236
0 commit comments