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..0f298f1 100644 --- a/pinterest/ads/ad_groups.py +++ b/pinterest/ads/ad_groups.py @@ -317,6 +317,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), 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 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",