Skip to content

Commit

Permalink
Fix conversion tag null config (#82)
Browse files Browse the repository at this point in the history
* Update generated client to 0.1.7

* Fix null configs for converion_tag

* Linting

* Feature fix/conversion tag configs (#83)

* Linting

* Update test
  • Loading branch information
thucngyyen committed Mar 6, 2023
1 parent 27f1041 commit 7d99b03
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 13 deletions.
32 changes: 31 additions & 1 deletion integration_tests/ads/test_conversion_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,42 @@ def test_create_conversion_tag_success(self):
"""
conversion_tag = ConversionTag.create(
ad_account_id = DEFAULT_AD_ACCOUNT_ID,
name = "Test Conversion Tag"
name = "Test Conversion Tag",
aem_enabled = None,
md_frequency = None,
aem_fnln_enabled = None,
aem_ph_enabled = None,
aem_ge_enabled = None,
aem_db_enabled = None,
aem_loc_enabled = None,
)

assert conversion_tag
assert getattr(conversion_tag, "_id")
assert getattr(conversion_tag, "_name") == "Test Conversion Tag"
assert getattr(conversion_tag.configs, "aem_enabled") == False

def test_create_conversion_tag_with_configs_success(self):
"""
Test creating a new Conversion Tag successfully
"""
conversion_tag = ConversionTag.create(
ad_account_id = DEFAULT_AD_ACCOUNT_ID,
name = "Test Conversion Tag",
aem_enabled = True,
md_frequency = 1.2,
aem_fnln_enabled = None,
aem_ph_enabled = None,
aem_ge_enabled = None,
aem_db_enabled = None,
aem_loc_enabled = None,
)

assert conversion_tag
assert getattr(conversion_tag, "_id")
assert getattr(conversion_tag, "_name") == "Test Conversion Tag"
assert getattr(conversion_tag.configs, "aem_enabled") == True
assert getattr(conversion_tag.configs, "md_frequency") == 1.2

class TestGetConversionTag(BaseTestCase):
"""
Expand Down
33 changes: 26 additions & 7 deletions pinterest/ads/conversion_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ def create(
cls,
ad_account_id : str,
name : str,
aem_enabled : bool = False,
md_frequency : float = 0.0,
aem_fnln_enabled : bool = False,
aem_ph_enabled : bool = False,
aem_ge_enabled : bool = False,
aem_db_enabled : bool = False,
aem_loc_enabled : bool = False,
aem_enabled : bool = None,
md_frequency : float = None,
aem_fnln_enabled : bool = None,
aem_ph_enabled : bool = None,
aem_ge_enabled : bool = None,
aem_db_enabled : bool = None,
aem_loc_enabled : bool = None,
client:PinterestSDKClient = None,
**kwargs
) -> ConversionTag:
Expand Down Expand Up @@ -147,6 +147,24 @@ def create(
Args:
ad_account_id (str): ConversionTag's Ad Account ID
name (str): ConversionTag name
aem_enabled (bool=False, Nullable): Whether Automatic Enhanced Match email is enabled. See\
Enhanced match for more information.
md_frequency (float=1.0, Nullable): Metadata ingestion frequency.
aem_fnln_enabled (bool=False, Nullable): Whether Automatic Enhanced Match name is enabled. See\
Enhanced match for more information.
aem_ph_enabled (bool=False, Nullable): Whether Automatic Enhanced Match phone is enabled. See\
Enhanced match for more information.
aem_ge_enabled (bool=False, Nullable): Whether Automatic Enhanced Match gender is enabled. See\
Enhanced match for more information.
aem_db_enabled (bool=False, Nullable): Whether Automatic Enhanced Match birthdate is enabled. See\
Enhanced match for more information.
aem_loc_enabled (bool=False, Nullable): Whether Automatic Enhanced Match location is enabled. See\
Enhanced match for more information.
Returns:
ConversionTag: ConversionTag Object
Expand All @@ -171,6 +189,7 @@ def create(
map_fn = lambda obj : obj,
)


return cls(
ad_account_id = response.ad_account_id,
conversion_tag_id = response.id,
Expand Down
6 changes: 3 additions & 3 deletions pinterest/organic/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def create(
client:PinterestSDKClient = None,
**kwargs
) -> Pin:
# pylint: disable=too-many-arguments
"""
Create a Pin on a board or board section owned by the "operation user_account".
Expand Down Expand Up @@ -197,6 +196,7 @@ def create(
Returns:
Pin: Pin object
"""
# pylint: disable=too-many-arguments, no-value-for-parameter

if not client:
client = cls._get_client()
Expand All @@ -212,9 +212,9 @@ def create(
board_section_id=board_section_id,
media_source=media_source,
parent_pin_id=parent_pin_id,
**kwargs
**kwargs,
)
)
) # pylint: disable=no-value-for-parameter
verify_api_response(api_response)

return Pin(pin_id=getattr(api_response, "id"), client=client)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pinterest-Generated-Client==0.1.5
Pinterest-Generated-Client==0.1.7
python-dateutil==2.8.2
six==1.16.0
urllib3==1.26.12
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _get_prod_version():
"python-dateutil",
"python-dotenv==0.20.0",
"six==1.16.0",
"Pinterest-Generated-Client==0.1.5"
"Pinterest-Generated-Client==0.1.7"
]

long_description = (Path(__file__).parent / "README.md").read_text()
Expand Down
1 change: 1 addition & 0 deletions tests/src/pinterest/ads/test_ad_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def test_create_ad_group_model_new_ad_group(self, ad_group_get_mock, ad_group_cr
campaign_id=self.test_campaign_id,
billable_event='CLICKTHROUGH',
name='SDK_TEST_CLIENT_ADGROUP',
auto_targeting_enabled=False
)

assert created_ad_group
Expand Down

2 comments on commit 7d99b03

@Lonzarostore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pinterest/ads/conversion_tags.py

@Lonzarostore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello hoe repareer ik het

Please sign in to comment.