44import mock
55
66from unittest import TestCase
7- from src .api import CmixAPI , CMIX_SERVICES
8- from src .error import CmixError
7+ from CmixAPIClient .api import CmixAPI , CMIX_SERVICES
8+ from CmixAPIClient .error import CmixError
99
1010
1111def default_cmix_api ():
@@ -72,15 +72,15 @@ def test_create_export_archive(self):
7272 self .assertEqual (response ['response' ], 1 )
7373
7474 def test_create_export_archive_errors_handled (self ):
75- with mock .patch ('src .api.requests.post' ) as mock_post :
75+ with mock .patch ('CmixAPIClient .api.requests.post' ) as mock_post :
7676 mock_post_response = mock .Mock ()
7777 mock_post_response .status_code = 200
7878 mock_post_response .json .return_value = {
7979 'response' : 1 ,
8080 'error' : 'Oops!' ,
8181 }
8282 mock_post .return_value = mock_post_response
83- with mock .patch ('src .api.requests.get' ) as mock_get :
83+ with mock .patch ('CmixAPIClient .api.requests.get' ) as mock_get :
8484 # Check CmixError is raised if POST response JSON includes an error.
8585 mock_response = mock .Mock ()
8686 mock_response .status_code = 200
@@ -95,7 +95,7 @@ def test_create_export_archive_errors_handled(self):
9595 # Remove error from POST response.
9696 mock_post_response .json .return_value = {'response' : 1 }
9797
98- with mock .patch ('src .api.requests.get' ) as mock_get :
98+ with mock .patch ('CmixAPIClient .api.requests.get' ) as mock_get :
9999 # Check CmixError is raised on GET 500 response. (layout response)
100100 mock_response = mock .Mock ()
101101 mock_response .status_code = 500
@@ -119,7 +119,7 @@ def test_create_export_archive_errors_handled(self):
119119 def test_get_survey_status (self ):
120120 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
121121
122- with mock .patch ('src .api.requests' ) as mock_request :
122+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
123123 mock_get = mock .Mock ()
124124 mock_get .status_code = 200
125125 mock_get .json .return_value = {'status' : 'LIVE' }
@@ -134,7 +134,7 @@ def test_get_survey_status(self):
134134 def test_get_survey_status_error_handled (self ):
135135 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
136136
137- with mock .patch ('src .api.requests' ) as mock_request :
137+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
138138 mock_get = mock .Mock ()
139139 mock_get .status_code = 200
140140 mock_get .json .return_value = {}
@@ -148,7 +148,7 @@ def test_get_survey_test_url(self):
148148 correct_test_link = '{}/#/?cmixSvy={}&cmixTest={}' .format (
149149 CMIX_SERVICES ['test' ]['BASE_URL' ], self .survey_id , 'test' )
150150
151- with mock .patch ('src .api.requests' ) as mock_request :
151+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
152152 mock_get = mock .Mock ()
153153 mock_get .status_code = 200
154154 mock_get .json .return_value = {'testToken' : 'test' }
@@ -158,7 +158,7 @@ def test_get_survey_test_url(self):
158158
159159 def test_get_survey_test_url_no_token_handled (self ):
160160 self .cmix_api ._authentication_headers = {'Authentication' : 'Bearer test' }
161- with mock .patch ('src .api.requests' ) as mock_request :
161+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
162162 mock_get = mock .Mock ()
163163 mock_get .status_code = 200
164164 mock_get .json .return_value = {}
@@ -168,7 +168,7 @@ def test_get_survey_test_url_no_token_handled(self):
168168 self .cmix_api .get_survey_test_url (self .survey_id )
169169
170170 def test_get_survey_completes (self ):
171- with mock .patch ('src .api.requests' ) as mock_request :
171+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
172172 mock_post = mock .Mock ()
173173 mock_post .status_code = 200
174174 mock_post .json .return_value = {
@@ -184,7 +184,7 @@ def test_get_survey_completes(self):
184184 self .assertEqual (self .cmix_api .get_survey_completes (self .survey_id ), mock_respondents )
185185
186186 def test_get_surveys (self ):
187- with mock .patch ('src .api.requests' ) as mock_request :
187+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
188188 mock_post = mock .Mock ()
189189 mock_post .status_code = 200
190190 mock_post .json .return_value = {
@@ -208,7 +208,7 @@ def test_get_surveys(self):
208208 mock_request .get .assert_any_call (expected_url_with_params , headers = self .cmix_api ._authentication_headers )
209209
210210 def test_fetch_banner_filter (self ):
211- with mock .patch ('src .api.requests' ) as mock_request :
211+ with mock .patch ('CmixAPIClient .api.requests' ) as mock_request :
212212 mock_post = mock .Mock ()
213213 mock_post .status_code = 200
214214 mock_post .json .return_value = {
@@ -245,7 +245,7 @@ def test_get_archive_status(self):
245245 survey_id = 1337
246246 archive_id = 12
247247 layout_id = 1
248- with mock .patch ('src .api.requests.get' ) as mock_request :
248+ with mock .patch ('CmixAPIClient .api.requests.get' ) as mock_request :
249249 mock_response = mock .Mock ()
250250 mock_response .status_code = 200
251251 mock_response .json .return_value = {
0 commit comments