Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update integration tests #120

Closed
wants to merge 7 commits into from
Closed

Conversation

gilderlane
Copy link

@gilderlane gilderlane commented Oct 4, 2023

Update required Pinterest-Generated-Client version
Update Pin and Board models with new properties
Update integration tests

new_spec = {
"GENDER": ["male"]
}
new_spec = TargetingSpec(gender=["male"])
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be using models directly like this from the generated client. we need a copy of its implementation in the SDK and then use that if needed. Was there an issue with just using what we had earlier?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, we started to get ApiTypeError: Invalid type for variable 'targeting_spec' for what we had for new_spec previously

ad_group_id=self.ad_group_utils.get_ad_group_id(),
creative_type="REGULAR",
ad_group_id=DEFAULT_AD_GROUP_ID,
creative_type="IDEA",
Copy link
Member

Choose a reason for hiding this comment

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

REGULAR format pins are more common and will always stay. I think we should stick to creating an ad using that creative type instead of IDEA as it is a new creative type and we may see changes there.

@@ -8,6 +8,8 @@
from pinterest.client import PinterestSDKClient
from pinterest.ads.conversion_events import Conversion

from openapi_generated.pinterest_client.exceptions import ApiException
Copy link
Member

Choose a reason for hiding this comment

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

Why are we importing this? I do not see any uses of it in the file. If we need one, there is an SDKException class defined, please use that instead.

Copy link
Author

Choose a reason for hiding this comment

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

The ApiException is the one raised when wrong params format is passed, which is the case tested in test_send_conversion_fail(). This is the reason why I test if its raised the failure test and therefore import it.

@@ -212,7 +212,7 @@ def __init__(self, client=None):
self.ad = Ad.create(
ad_account_id=DEFAULT_AD_ACCOUNT_ID,
ad_group_id=getattr(self.ad_group, "_id"),
creative_type="REGULAR",
creative_type="IDEA",
Copy link
Member

Choose a reason for hiding this comment

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

Please change this to REGULAR for reasons explained above. Unless there is an issue which you can explain here.

Copy link
Author

@gilderlane gilderlane Oct 5, 2023

Choose a reason for hiding this comment

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

The default test pin associated to the ad created in the integration tests is an IDEA pin. It was created via the UI, and has only one image, but only IDEA ads are elegible for it

@@ -232,7 +232,7 @@ def get_default_params(self):
return dict(
ad_account_id=DEFAULT_AD_ACCOUNT_ID,
ad_group_id=getattr(self.ad_group, "_id"),
creative_type="REGULAR",
creative_type="IDEA",
Copy link
Member

Choose a reason for hiding this comment

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

Please change this to REGULAR for reasons explained above.

Comment on lines +82 to +83
if pin_id != DEFAULT_PIN_ID: # Make sure default pin is not being deleted
return Pin.delete(pin_id=pin_id, client=self.test_client)
Copy link
Member

Choose a reason for hiding this comment

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

Can you add some sort of logging here? Or a print statement or something? Something that indicates

  1. Default pin was tried to be deleted
  2. Or, it didn't actually delete the pin that was trying to be deleted

Copy link
Author

Choose a reason for hiding this comment

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

Added

@@ -8,6 +8,7 @@
from openapi_generated.pinterest_client.model.ad_group_response import AdGroupResponse
from openapi_generated.pinterest_client.model.ad_group_array_response import AdGroupArrayResponse
from openapi_generated.pinterest_client.model.ad_group_array_response_element import AdGroupArrayResponseElement
from openapi_generated.pinterest_client.model.targeting_spec import TargetingSpec
Copy link
Member

Choose a reason for hiding this comment

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

Change this for reasons explained above.

Comment on lines -89 to -95
assert response
assert response.num_events_received == 2
assert response.num_events_processed == 0
assert len(response.events) == 2

assert 'hashed format' in response.events[0].error_message
assert 'hashed format' in response.events[0].error_message
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we keep asserts?

@dfana01 dfana01 deleted the feature-test/fix-integration-tests branch November 15, 2024 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants