@@ -139,7 +139,7 @@ def test_exchange_code_for_tokens_success(self, mock_post):
139139 mock_post .return_value = mock_response
140140
141141 # Mock cloud ID retrieval and token saving
142- with patch . object ( OAuthConfig , "_get_cloud_id " ) as mock_get_cloud_id :
142+ with patch ( "mcp_atlassian.utils.oauth.get_cloud_id " ) as mock_get_cloud_id :
143143 with patch .object (OAuthConfig , "_save_tokens" ) as mock_save_tokens :
144144 config = OAuthConfig (
145145 client_id = "test-client-id" ,
@@ -157,7 +157,7 @@ def test_exchange_code_for_tokens_success(self, mock_post):
157157
158158 # Verify calls
159159 mock_post .assert_called_once ()
160- mock_get_cloud_id .assert_called_once ( )
160+ mock_get_cloud_id .assert_called_once_with ( "new-access-token" )
161161 mock_save_tokens .assert_called_once ()
162162
163163 @patch ("requests.post" )
@@ -284,42 +284,33 @@ def test_ensure_valid_token_needs_refresh_failure(self, mock_refresh):
284284
285285 @patch ("requests.get" )
286286 def test_get_cloud_id_success (self , mock_get ):
287- """Test _get_cloud_id success case."""
287+ """Test get_cloud_id success case."""
288288 # Mock response
289289 mock_response = MagicMock ()
290290 mock_response .status_code = 200
291291 mock_response .json .return_value = [{"id" : "test-cloud-id" , "name" : "Test Site" }]
292292 mock_get .return_value = mock_response
293293
294- config = OAuthConfig (
295- client_id = "test-client-id" ,
296- client_secret = "test-client-secret" ,
297- redirect_uri = "https://example.com/callback" ,
298- scope = "read:jira-work write:jira-work" ,
299- access_token = "test-access-token" ,
300- )
301- config ._get_cloud_id ()
294+ from mcp_atlassian .utils .oauth import get_cloud_id
295+
296+ cloud_id = get_cloud_id ("test-access-token" )
302297
303298 # Check result
304- assert config . cloud_id == "test-cloud-id"
299+ assert cloud_id == "test-cloud-id"
305300 mock_get .assert_called_once ()
306301 headers = mock_get .call_args [1 ]["headers" ]
307302 assert headers ["Authorization" ] == "Bearer test-access-token"
308303
309304 @patch ("requests.get" )
310305 def test_get_cloud_id_no_access_token (self , mock_get ):
311- """Test _get_cloud_id with no access token."""
312- config = OAuthConfig (
313- client_id = "test-client-id" ,
314- client_secret = "test-client-secret" ,
315- redirect_uri = "https://example.com/callback" ,
316- scope = "read:jira-work write:jira-work" ,
317- )
318- config ._get_cloud_id ()
306+ """Test get_cloud_id with no access token."""
307+ from mcp_atlassian .utils .oauth import get_cloud_id
308+
309+ cloud_id = get_cloud_id (None )
319310
320311 # Should not make API call without token
321312 mock_get .assert_not_called ()
322- assert config . cloud_id is None
313+ assert cloud_id is None
323314
324315 def test_get_keyring_username (self ):
325316 """Test _get_keyring_username method."""
0 commit comments