From e8ae9ca82bc11beff0e7e41b29328e4e447c46a2 Mon Sep 17 00:00:00 2001 From: Bharadwaj P Date: Wed, 30 Oct 2024 12:56:01 -0700 Subject: [PATCH 1/4] Loosen requirements for urllib3 version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5ee48de..37d5153 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Pinterest-Generated-Client==0.1.9 python-dateutil==2.8.2 six==1.16.0 -urllib3==1.26.12 +urllib3>=1.26.12 python-dotenv==0.20.0 From ca27d89dd6c48e9c4fdf731a3427dcbed4723595 Mon Sep 17 00:00:00 2001 From: Bharadwaj P Date: Wed, 30 Oct 2024 13:00:23 -0700 Subject: [PATCH 2/4] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 103c917..abdfbfb 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def _get_prod_version(): _IS_TEST_BUILD = os.environ.get("IS_TEST_BUILD", 0) REQUIRES = [ - "urllib3==1.26.12", + "urllib3>=1.26.12", "python-dateutil", "python-dotenv==0.20.0", "six==1.16.0", From 6da6ade94f335cd0aa0790649e2a23d2d52fff95 Mon Sep 17 00:00:00 2001 From: Dante <{ID}+{username}@users.noreply.github.com> Date: Thu, 20 Mar 2025 00:52:31 -0400 Subject: [PATCH 3/4] fix: integration tests --- config.json | 1 + integration_tests/ads/test_ad_groups.py | 15 +++++++++++++-- integration_tests/ads/test_campaigns.py | 4 ++++ integration_tests/utils/ads_utils.py | 8 ++++++++ pinterest/ads/ad_groups.py | 4 ++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..390ba5f --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{"state":"package_test"} diff --git a/integration_tests/ads/test_ad_groups.py b/integration_tests/ads/test_ad_groups.py index f40c5b8..4a3ceb8 100644 --- a/integration_tests/ads/test_ad_groups.py +++ b/integration_tests/ads/test_ad_groups.py @@ -25,6 +25,10 @@ def test_create_ad_group_success(self): name="SDK_INTEGRATION_TEST_ADGROUP", auto_targeting_enabled=False, bid_in_micro_currency=10000000, + targeting_spec=dict( + age_bucket=["35-44"], + location=["US"], + ) ) assert ad_group @@ -63,7 +67,10 @@ def test_update_success(self): ) new_name = "SDK_AD_GROUP_NEW_NAME" - new_spec = {"gender": ["male"]} + new_spec = { + "age_bucket":["35-44"], + "location": ["US"], + } ad_group.update_fields( name=new_name, @@ -72,7 +79,7 @@ def test_update_success(self): assert ad_group assert getattr(ad_group, "_name") == new_name - assert str(getattr(ad_group,"_targeting_spec")) == str(new_spec) + assert str(getattr(ad_group,"_targeting_spec")).lower() == str(new_spec).lower() def test_update_fail_with_invalid_tracking_urls(self): """ @@ -138,6 +145,10 @@ def test_get_list_with_campaign_ids_success(self): name="SDK_INTEGRATION_TEST_ADGROUP", auto_targeting_enabled=False, bid_in_micro_currency=10000000, + targeting_spec=dict( + age_bucket=["35-44"], + location=["US"], + ) ) new_ad_groups = AdGroup.get_all( diff --git a/integration_tests/ads/test_campaigns.py b/integration_tests/ads/test_campaigns.py index f56cb01..f30055d 100644 --- a/integration_tests/ads/test_campaigns.py +++ b/integration_tests/ads/test_campaigns.py @@ -186,6 +186,10 @@ def test_list_ad_groups(self): name="SDK_INTEGRATION_TEST_ADGROUP", auto_targeting_enabled=False, bid_in_micro_currency=10000000, + targeting_spec=dict( + age_bucket=["35-44"], + location=["US"], + ) ) ) diff --git a/integration_tests/utils/ads_utils.py b/integration_tests/utils/ads_utils.py index 5aaa22d..51829c4 100644 --- a/integration_tests/utils/ads_utils.py +++ b/integration_tests/utils/ads_utils.py @@ -144,6 +144,10 @@ def __init__(self, client=None): name="SDK_INTEGRATION_TEST_ADGROUP", auto_targeting_enabled=False, bid_in_micro_currency=10000000, + targeting_spec=dict( + age_bucket=["35-44"], + location=["US"], + ) ) self.ad_group_id = self.ad_group._id @@ -162,6 +166,10 @@ def get_default_params(self): name="SDK_INTEGRATION_TEST_ADGROUP", auto_targeting_enabled=False, bid_in_micro_currency=10000000, + targeting_spec=dict( + age_bucket=["35-44"], + location=["US"], + ) ) def create_new_ad_group(self, **kwargs): diff --git a/pinterest/ads/ad_groups.py b/pinterest/ads/ad_groups.py index fcfac7d..deddcf9 100644 --- a/pinterest/ads/ad_groups.py +++ b/pinterest/ads/ad_groups.py @@ -11,6 +11,7 @@ from openapi_generated.pinterest_client.model.ad_group_create_request import AdGroupCreateRequest from openapi_generated.pinterest_client.model.ad_group_update_request import AdGroupUpdateRequest from openapi_generated.pinterest_client.model.targeting_spec import TargetingSpec +from openapi_generated.pinterest_client.model.targeting_spec_shoppingretargeting import TargetingSpecSHOPPINGRETARGETING from pinterest.client import PinterestSDKClient from pinterest.utils.base_model import PinterestBaseModel @@ -317,6 +318,9 @@ def create( Returns: AdGroup: AdGroup Object """ + if "targeting_spec" in kwargs: + kwargs["targeting_spec"] = TargetingSpec(**kwargs["targeting_spec"]) + response = cls._create( params={ "ad_account_id": str(ad_account_id), From c9e9c4e30460d88e4674ff89c6d377f1f111e217 Mon Sep 17 00:00:00 2001 From: Dante <{ID}+{username}@users.noreply.github.com> Date: Thu, 20 Mar 2025 00:55:43 -0400 Subject: [PATCH 4/4] fix: lint --- pinterest/ads/ad_groups.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pinterest/ads/ad_groups.py b/pinterest/ads/ad_groups.py index deddcf9..0f298f1 100644 --- a/pinterest/ads/ad_groups.py +++ b/pinterest/ads/ad_groups.py @@ -11,7 +11,6 @@ from openapi_generated.pinterest_client.model.ad_group_create_request import AdGroupCreateRequest from openapi_generated.pinterest_client.model.ad_group_update_request import AdGroupUpdateRequest from openapi_generated.pinterest_client.model.targeting_spec import TargetingSpec -from openapi_generated.pinterest_client.model.targeting_spec_shoppingretargeting import TargetingSpecSHOPPINGRETARGETING from pinterest.client import PinterestSDKClient from pinterest.utils.base_model import PinterestBaseModel