1- """Unit tests for refactored refresh_token and get_authentication_token functions."""
1+ """Unit tests for refactored refresh_token and get_authentication_token_set functions."""
22
33from unittest .mock import patch
44
5- from src .auth .browser_auth import refresh_token , get_authentication_token
5+ from src .auth .browser_auth import get_authentication_token_set , refresh_token
66from tests .models import (
77 TokenSetModel ,
88 TokenValidationResult ,
@@ -146,7 +146,7 @@ def test_refresh_token_with_default_parameters(self):
146146
147147
148148class TestGetAuthenticationToken :
149- """Test cases for the refactored get_authentication_token function."""
149+ """Test cases for the refactored get_authentication_token_set function."""
150150
151151 @patch ("src.auth.browser_auth.check_saved_credentials" )
152152 @patch ("src.auth.browser_auth.validate_token_for_refresh" )
@@ -165,10 +165,11 @@ def test_get_authentication_token_valid_saved_token(
165165 mock_validate .return_value = validation_result
166166
167167 # Act
168- result = get_authentication_token ()
168+ result = get_authentication_token_set ()
169169
170170 # Assert
171- assert result == "valid_token"
171+ assert result is not None
172+ assert result .access_token == "valid_token"
172173 mock_check_creds .assert_called_once ()
173174 mock_validate .assert_called_once_with (token_set )
174175
@@ -201,10 +202,11 @@ def test_get_authentication_token_refresh_success(
201202 mock_attempt_refresh .return_value = refreshed_token_set
202203
203204 # Act
204- result = get_authentication_token ()
205+ result = get_authentication_token_set ()
205206
206207 # Assert
207- assert result == "refreshed_token"
208+ assert result is not None
209+ assert result .access_token == "refreshed_token"
208210 mock_check_creds .assert_called_once ()
209211 mock_validate .assert_called_once_with (expired_token_set )
210212 mock_attempt_refresh .assert_called_once ()
@@ -241,10 +243,11 @@ def test_get_authentication_token_refresh_failed_auth_success(
241243 mock_authenticate .return_value = (True , new_token_set )
242244
243245 # Act
244- result = get_authentication_token ()
246+ result = get_authentication_token_set ()
245247
246248 # Assert
247- assert result == "new_auth_token"
249+ assert result is not None
250+ assert result .access_token == "new_auth_token"
248251 mock_check_creds .assert_called_once ()
249252 mock_validate .assert_called_once_with (expired_token_set )
250253 mock_attempt_refresh .assert_called_once ()
@@ -263,10 +266,11 @@ def test_get_authentication_token_no_saved_credentials(
263266 mock_authenticate .return_value = (True , new_token_set )
264267
265268 # Act
266- result = get_authentication_token ()
269+ result = get_authentication_token_set ()
267270
268271 # Assert
269- assert result == "new_token"
272+ assert result is not None
273+ assert result .access_token == "new_token"
270274 mock_check_creds .assert_called_once ()
271275 mock_authenticate .assert_called_once ()
272276
@@ -280,10 +284,11 @@ def test_get_authentication_token_force_reauth(self, mock_authenticate):
280284 mock_authenticate .return_value = (True , new_token_set )
281285
282286 # Act
283- result = get_authentication_token (force_reauth = True )
287+ result = get_authentication_token_set (force_reauth = True )
284288
285289 # Assert
286- assert result == "force_auth_token"
290+ assert result is not None
291+ assert result .access_token == "force_auth_token"
287292 mock_authenticate .assert_called_once ()
288293
289294 @patch ("src.auth.browser_auth.authenticate" )
@@ -297,7 +302,7 @@ def test_get_authentication_token_auth_failure(
297302 mock_authenticate .return_value = (False , None )
298303
299304 # Act
300- result = get_authentication_token ()
305+ result = get_authentication_token_set ()
301306
302307 # Assert
303308 assert result is None
@@ -315,7 +320,7 @@ def test_get_authentication_token_auth_success_no_token(
315320 mock_authenticate .return_value = (True , None )
316321
317322 # Act
318- result = get_authentication_token ()
323+ result = get_authentication_token_set ()
319324
320325 # Assert
321326 assert result is None
@@ -339,12 +344,13 @@ def test_get_authentication_token_with_custom_parameters(self):
339344 mock_authenticate .return_value = (True , new_token_set )
340345
341346 # Act
342- result = get_authentication_token (
347+ result = get_authentication_token_set (
343348 client_id = client_id , oauth_host = oauth_host , auth_timeout = auth_timeout
344349 )
345350
346351 # Assert
347- assert result == "custom_token"
352+ assert result is not None
353+ assert result .access_token == "custom_token"
348354 mock_authenticate .assert_called_once_with (
349355 client_id , oauth_host , auth_timeout
350356 )
0 commit comments