@@ -173,38 +173,42 @@ def real_app_client(self):
173173 pytest .skip ("Cannot import callback module due to dependencies" )
174174
175175 @patch ('api.callback.db' )
176- @patch ('util.spotify.get_user_profile ' )
176+ @patch ('util.spotify.get_user_profile_raw ' )
177177 @patch ('util.spotify.generate_token' )
178178 @patch ('util.spotify.BASE_URL' , 'http://localhost:5000' )
179- def test_successful_integration_callback (self , mock_generate_token , mock_get_user_profile , mock_db , real_app_client ):
179+ def test_successful_integration_callback (self , mock_generate_token , mock_get_user_profile_raw , mock_db , real_app_client ):
180180 """Test successful callback integration with all components."""
181181 # Mock Spotify API responses
182182 mock_generate_token .return_value = {
183183 "access_token" : "test_access_token" ,
184- "refresh_token" : "test_refresh_token" ,
184+ "refresh_token" : "test_refresh_token" ,
185185 "expires_in" : 3600
186186 }
187-
188- mock_get_user_profile .return_value = {
187+
188+ mock_profile_response = MagicMock ()
189+ mock_profile_response .status_code = 200
190+ mock_profile_response .text = '{"id": "test_user_123", "display_name": "Test User"}'
191+ mock_profile_response .json .return_value = {
189192 "id" : "test_user_123" ,
190193 "display_name" : "Test User"
191194 }
192-
195+ mock_get_user_profile_raw .return_value = mock_profile_response
196+
193197 # Mock Firestore
194198 mock_collection = MagicMock ()
195199 mock_document = MagicMock ()
196200 mock_db .collection .return_value = mock_collection
197201 mock_collection .document .return_value = mock_document
198-
202+
199203 # Make request with authorization code
200204 response = real_app_client .get ("/?code=test_auth_code" )
201-
205+
202206 # Verify response
203207 assert response .status_code == 200
204-
208+
205209 # Verify Spotify API calls
206210 mock_generate_token .assert_called_once_with ("test_auth_code" )
207- mock_get_user_profile .assert_called_once_with ("test_access_token" )
211+ mock_get_user_profile_raw .assert_called_once_with ("test_access_token" )
208212
209213 # Verify Firestore operations
210214 mock_db .collection .assert_called_once_with ("users" )
0 commit comments