From 6e5bee75c043041c8db85578cbb00e7e9bff5da9 Mon Sep 17 00:00:00 2001 From: Amol Mundayoor Date: Fri, 28 Aug 2026 19:11:28 -0700 Subject: [PATCH] chore: bump Pinterest-Generated-Client to 0.1.12 and update integration tests Update integration tests to match new generated client behavior: - API errors now surface as ApiException instead of SdkException/AssertionError - Campaign creation requires is_campaign_budget_optimization=True for the test account --- integration_tests/ads/test_ad_groups.py | 6 +++++- integration_tests/ads/test_campaigns.py | 5 +++++ integration_tests/ads/test_keywords.py | 6 ++++-- integration_tests/utils/ads_utils.py | 6 ++++++ requirements.txt | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/integration_tests/ads/test_ad_groups.py b/integration_tests/ads/test_ad_groups.py index 4a3ceb8..43f85e7 100644 --- a/integration_tests/ads/test_ad_groups.py +++ b/integration_tests/ads/test_ad_groups.py @@ -7,6 +7,8 @@ from pinterest.ads.ad_groups import AdGroup +from openapi_generated.pinterest_client.exceptions import ApiException + class TestCreateAdGroup(BaseTestCase): ''' @@ -103,7 +105,9 @@ def test_update_fail_with_invalid_tracking_urls(self): tracking_urls=new_tracking_url ) - with self.assertRaises(AssertionError): + # The API now rejects unsupported tracking-URL event types with HTTP 400, + # which the generated client raises as ApiException. + with self.assertRaises(ApiException): ad_group.update_fields(**update_argument) diff --git a/integration_tests/ads/test_campaigns.py b/integration_tests/ads/test_campaigns.py index f30055d..bb5fd52 100644 --- a/integration_tests/ads/test_campaigns.py +++ b/integration_tests/ads/test_campaigns.py @@ -31,6 +31,7 @@ def test_create_campaign_success(self): name="SDK Test Campaign", objective_type="AWARENESS", daily_spend_cap=10000000, + is_campaign_budget_optimization=True, ) assert campaign @@ -43,11 +44,15 @@ def test_create_campaign_failure_without_budget(self): """ Verify a new Campaign response failure and catching exceptions """ + # This ad account requires Campaign Budget Optimization, so CBO must be on; + # with CBO on and no spend cap the API reports the missing-budget error 2384 + # (CBO campaigns need [lifetime_spend_cap and end_time] or daily_spend_cap). campaign_arguments = dict( client=self.test_client, ad_account_id=DEFAULT_AD_ACCOUNT_ID, name="SDK Test Campaign", objective_type="AWARENESS", + is_campaign_budget_optimization=True, ) self.assertRaisesRegex( diff --git a/integration_tests/ads/test_keywords.py b/integration_tests/ads/test_keywords.py index b745543..eaab8ab 100644 --- a/integration_tests/ads/test_keywords.py +++ b/integration_tests/ads/test_keywords.py @@ -8,8 +8,8 @@ from integration_tests.config import DEFAULT_AD_ACCOUNT_ID from pinterest.ads.keywords import Keyword -from pinterest.utils.sdk_exceptions import SdkException +from openapi_generated.pinterest_client.exceptions import ApiException from openapi_generated.pinterest_client.model.match_type_response import MatchTypeResponse @@ -44,7 +44,9 @@ def test_create_fail_without_matchtype(self): value="string", ) - with self.assertRaises(SdkException): + # Without a match_type the API rejects the request outright with HTTP 400 + # (match_type is not nullable), which the generated client raises as ApiException. + with self.assertRaises(ApiException): Keyword.create(**keyword_arguments) diff --git a/integration_tests/utils/ads_utils.py b/integration_tests/utils/ads_utils.py index 51829c4..c627dfe 100644 --- a/integration_tests/utils/ads_utils.py +++ b/integration_tests/utils/ads_utils.py @@ -109,6 +109,9 @@ def __init__(self, client=None): name="SDK Test Campaign", objective_type="AWARENESS", daily_spend_cap=10000000, + # This ad account requires Campaign Budget Optimization (ad-group level + # budgets are not allowed), so budgets must be set at the campaign level. + is_campaign_budget_optimization=True, ) self.campaign_id = self.campaign._id @@ -125,6 +128,9 @@ def get_default_params(self): name="SDK Test Campaign", objective_type="AWARENESS", daily_spend_cap=10000000, + # This ad account requires Campaign Budget Optimization (ad-group level + # budgets are not allowed), so budgets must be set at the campaign level. + is_campaign_budget_optimization=True, ) def create_new_campaign(self, **kwargs): diff --git a/requirements.txt b/requirements.txt index 2c0d4a6..7a7de31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Pinterest-Generated-Client==0.1.10 +Pinterest-Generated-Client==0.1.12 python-dateutil==2.8.2 six==1.16.0 urllib3>=1.26.12