@@ -30,7 +30,7 @@ async def test_dsa_requirement_detection_business_account(self):
3030 }
3131
3232 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
33- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
33+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
3434 mock_auth .return_value = "test_access_token"
3535 mock_api .return_value = mock_account_response
3636
@@ -62,7 +62,7 @@ async def test_dsa_requirement_detection_non_dsa_region(self):
6262 }
6363
6464 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
65- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
65+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
6666 mock_auth .return_value = "test_access_token"
6767 mock_api .return_value = mock_account_response
6868
@@ -81,7 +81,7 @@ async def test_dsa_requirement_detection_non_dsa_region(self):
8181 async def test_dsa_requirement_detection_error_handling (self ):
8282 """Test error handling when account info cannot be retrieved"""
8383 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
84- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
84+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
8585 mock_auth .return_value = "test_access_token"
8686 mock_api .side_effect = Exception ("API Error" )
8787
@@ -100,7 +100,7 @@ async def test_dsa_requirement_detection_error_handling(self):
100100 async def test_account_info_requires_account_id (self ):
101101 """Test that get_account_info requires an account_id parameter"""
102102
103- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
103+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
104104 mock_auth .return_value = "test_access_token"
105105
106106 # Test without account_id parameter
@@ -140,7 +140,7 @@ async def test_account_info_inaccessible_account_error(self):
140140 }
141141
142142 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
143- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
143+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
144144 mock_auth .return_value = "test_access_token"
145145 # First call returns permission error, second call returns accessible accounts
146146 mock_api .side_effect = [mock_permission_error , mock_accessible_accounts ]
@@ -175,7 +175,7 @@ async def test_create_adset_with_dsa_beneficiary_success(self):
175175 }
176176
177177 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
178- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
178+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
179179 mock_auth .return_value = "test_access_token"
180180 mock_api .return_value = mock_response
181181
@@ -209,7 +209,7 @@ async def test_create_adset_with_dsa_beneficiary_validation_error(self):
209209 }
210210
211211 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
212- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
212+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
213213 mock_auth .return_value = "test_access_token"
214214 mock_api .side_effect = Exception ("DSA beneficiary required for European compliance" )
215215
@@ -237,7 +237,7 @@ async def test_create_adset_with_dsa_beneficiary_validation_error(self):
237237 async def test_create_adset_without_dsa_beneficiary_dsa_required (self ):
238238 """Test error when DSA beneficiary is required but not provided"""
239239 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
240- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
240+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
241241 mock_auth .return_value = "test_access_token"
242242 mock_api .side_effect = Exception ("Enter the person or organization that benefits from ads in this ad set" )
243243
@@ -265,7 +265,7 @@ async def test_create_adset_without_dsa_beneficiary_dsa_required(self):
265265 async def test_create_adset_dsa_beneficiary_in_targeting (self ):
266266 """Test that DSA beneficiary is not added to targeting spec"""
267267 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
268- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
268+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
269269 mock_auth .return_value = "test_access_token"
270270 mock_api .return_value = {"id" : "23842588888640185" }
271271
@@ -300,7 +300,7 @@ async def test_create_adset_dsa_beneficiary_parameter_formats(self):
300300
301301 for beneficiary_name in test_cases :
302302 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
303- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
303+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
304304 mock_auth .return_value = "test_access_token"
305305 mock_api .return_value = {"id" : "23842588888640185" }
306306
@@ -326,7 +326,7 @@ class TestDSAPermissionHandling:
326326 async def test_dsa_beneficiary_missing_business_management_permission (self ):
327327 """Test error handling when business_management permissions are missing"""
328328 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
329- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
329+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
330330 mock_auth .return_value = "test_access_token"
331331 mock_api .side_effect = Exception ("Permission denied: business_management permission required" )
332332
@@ -354,7 +354,7 @@ async def test_dsa_beneficiary_missing_business_management_permission(self):
354354 async def test_dsa_beneficiary_api_limitation_handling (self ):
355355 """Test handling when API doesn't support dsa_beneficiary parameter"""
356356 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
357- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
357+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
358358 mock_auth .return_value = "test_access_token"
359359 mock_api .side_effect = Exception ("Parameter dsa_beneficiary is not supported" )
360360
@@ -397,7 +397,7 @@ async def test_dsa_compliance_european_regions(self):
397397 }
398398
399399 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
400- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
400+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
401401 mock_auth .return_value = "test_access_token"
402402 mock_api .return_value = mock_account_response
403403
@@ -422,7 +422,7 @@ async def test_dsa_compliance_non_european_regions(self):
422422 }
423423
424424 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
425- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
425+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
426426 mock_auth .return_value = "test_access_token"
427427 mock_api .return_value = mock_account_response
428428
@@ -451,7 +451,7 @@ async def test_dsa_beneficiary_validation_by_region(self):
451451
452452 # Test European account
453453 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
454- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
454+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
455455 mock_auth .return_value = "test_access_token"
456456 mock_api .return_value = european_mock_response
457457
@@ -462,7 +462,7 @@ async def test_dsa_beneficiary_validation_by_region(self):
462462
463463 # Test US account
464464 with patch ('meta_ads_mcp.core.accounts.make_api_request' , new_callable = AsyncMock ) as mock_api :
465- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
465+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
466466 mock_auth .return_value = "test_access_token"
467467 mock_api .return_value = us_mock_response
468468
@@ -487,7 +487,7 @@ async def test_dsa_beneficiary_clear_error_message(self):
487487
488488 for error_message , expected_keyword in error_scenarios :
489489 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
490- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
490+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
491491 mock_auth .return_value = "test_access_token"
492492 mock_api .side_effect = Exception (error_message )
493493
@@ -514,7 +514,7 @@ async def test_dsa_beneficiary_clear_error_message(self):
514514 async def test_dsa_beneficiary_fallback_behavior (self ):
515515 """Test fallback behavior for unexpected DSA-related errors"""
516516 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
517- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
517+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
518518 mock_auth .return_value = "test_access_token"
519519 mock_api .side_effect = Exception ("Unexpected DSA-related error" )
520520
@@ -562,7 +562,7 @@ async def test_get_adset_details_with_dsa_beneficiary(self):
562562 }
563563
564564 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
565- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
565+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
566566 mock_auth .return_value = "test_access_token"
567567 mock_api .return_value = mock_adset_response
568568
@@ -595,7 +595,7 @@ async def test_get_adset_details_without_dsa_beneficiary(self):
595595 }
596596
597597 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
598- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
598+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
599599 mock_auth .return_value = "test_access_token"
600600 mock_api .return_value = mock_adset_response
601601
@@ -625,7 +625,7 @@ async def test_get_adset_details_empty_dsa_beneficiary(self):
625625 }
626626
627627 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
628- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
628+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
629629 mock_auth .return_value = "test_access_token"
630630 mock_api .return_value = mock_adset_response
631631
@@ -640,7 +640,7 @@ async def test_get_adset_details_empty_dsa_beneficiary(self):
640640 async def test_get_adset_details_dsa_beneficiary_field_requested (self ):
641641 """Test that the API request includes dsa_beneficiary in the fields parameter"""
642642 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
643- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
643+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
644644 mock_auth .return_value = "test_access_token"
645645 mock_api .return_value = {"id" : "120229746629010183" }
646646
@@ -655,7 +655,7 @@ async def test_get_adset_details_dsa_beneficiary_field_requested(self):
655655 async def test_get_adset_details_error_handling (self ):
656656 """Test error handling when retrieving ad set details fails"""
657657 with patch ('meta_ads_mcp.core.adsets.make_api_request' , new_callable = AsyncMock ) as mock_api :
658- with patch ('meta_ads_mcp.core.api .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
658+ with patch ('meta_ads_mcp.core.auth .get_current_access_token' , new_callable = AsyncMock ) as mock_auth :
659659 mock_auth .return_value = "test_access_token"
660660 mock_api .side_effect = Exception ("Ad set not found" )
661661
0 commit comments