@@ -127,8 +127,9 @@ def test_authenticate_failure_empty_values(self, mock_requests):
127127 self .assertEqual (response .get ("code" ), 400 )
128128 self .assertEqual (response .get ("message" ), "Validation error" )
129129
130+ @patch ("loading_api_wrapper.api.LoadingApiWrapper._authenticate" )
130131 @patch ("loading_api_wrapper.api.requests" )
131- def test_get_profile_success (self , mock_requests ):
132+ def test_get_profile_success (self , mock_requests , mock_authenticate ):
132133 status_code = 200
133134 expected_response = {
134135 "id" : "000000000000000000000000" ,
@@ -142,18 +143,15 @@ def test_get_profile_success(self, mock_requests):
142143 mock_response .status_code = status_code
143144 mock_response .json .return_value = expected_response
144145 mock_requests .get .return_value = mock_response
146+ mock_authenticate .return_value = {"code" : 200 , "cookies" : self .cookie_jar }
145147
146- with patch (
147- "loading_api_wrapper.api.LoadingApiWrapper._authenticate"
148- ) as mock_auth :
149- mock_auth .return_value = {"code" : 200 , "cookies" : self .cookie_jar }
150- api = LoadingApiWrapper ("test@email.com" , "password" )
151- response = api .get_profile ()
152-
153- self .assertIsNotNone (api .cookies )
154- self .assertEqual (api .cookies , self .cookie_jar )
155- self .assertEqual (response .get ("code" ), 200 )
156- self .assertDictEqual (response .get ("profile" ), expected_response )
148+ api = LoadingApiWrapper ("test@email.com" , "password" )
149+ response = api .get_profile ()
150+
151+ self .assertIsNotNone (api .cookies )
152+ self .assertEqual (api .cookies , self .cookie_jar )
153+ self .assertEqual (response .get ("code" ), 200 )
154+ self .assertDictEqual (response .get ("profile" ), expected_response )
157155
158156 @patch ("loading_api_wrapper.api.requests" )
159157 def test_get_profile_failure (self , mock_requests ):
0 commit comments