-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: main
Are you sure you want to change the base?
Changes from all commits
a9dffc8
f69bf6f
6bde6a3
4e26981
c5e0eb6
b908ee8
382e1a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
from openapi_generated.pinterest_client.model.entity_status import EntityStatus | ||
|
||
from integration_tests.base_test import BaseTestCase | ||
from integration_tests.config import DEFAULT_PIN_ID, DEFAULT_AD_ACCOUNT_ID | ||
from integration_tests.config import DEFAULT_PIN_ID, DEFAULT_AD_ACCOUNT_ID, DEFAULT_AD_GROUP_ID | ||
|
||
|
||
class TestCreateAd(BaseTestCase): | ||
|
@@ -23,8 +23,8 @@ def test_create_ad_success(self): | |
""" | ||
ad = Ad.create( | ||
ad_account_id=DEFAULT_AD_ACCOUNT_ID, | ||
ad_group_id=self.ad_group_utils.get_ad_group_id(), | ||
creative_type="REGULAR", | ||
ad_group_id=DEFAULT_AD_GROUP_ID, | ||
creative_type="IDEA", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
pin_id=DEFAULT_PIN_ID, | ||
name="Test_create_ad", | ||
status="ACTIVE", | ||
|
@@ -43,7 +43,7 @@ def test_create_ad_failure_without_creative_type(self): | |
""" | ||
ad_arguments = dict( | ||
ad_account_id=DEFAULT_AD_ACCOUNT_ID, | ||
ad_group_id=self.ad_group_utils.get_ad_group_id(), | ||
ad_group_id=DEFAULT_AD_GROUP_ID, | ||
pin_id=DEFAULT_PIN_ID, | ||
name="Test_create_ad", | ||
status="ACTIVE", | ||
|
@@ -59,7 +59,7 @@ def test_create_ad_failure_with_incorrect_creative_type(self): | |
""" | ||
ad_arguments = dict( | ||
ad_account_id=DEFAULT_AD_ACCOUNT_ID, | ||
ad_group_id=self.ad_group_utils.get_ad_group_id(), | ||
ad_group_id=DEFAULT_AD_GROUP_ID, | ||
creative_type="NOT", | ||
pin_id=DEFAULT_PIN_ID, | ||
name="Test_create_ad", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
from pinterest.client import PinterestSDKClient | ||
from pinterest.ads.conversion_events import Conversion | ||
|
||
from openapi_generated.pinterest_client.exceptions import ApiException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
class TestSendConversionEvent(BaseTestCase): | ||
""" | ||
Test send Conversion Event | ||
|
@@ -79,17 +81,10 @@ def test_send_conversion_fail(self): | |
for _ in range(NUMBER_OF_CONVERSION_EVENTS) | ||
] | ||
|
||
response = Conversion.send_conversion_events( | ||
client = client, | ||
ad_account_id = DEFAULT_AD_ACCOUNT_ID, | ||
conversion_events = conversion_events, | ||
test = True, | ||
) | ||
|
||
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 | ||
Comment on lines
-89
to
-95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we keep asserts? |
||
with self.assertRaises(ApiException): | ||
Conversion.send_conversion_events( | ||
client = client, | ||
ad_account_id = DEFAULT_AD_ACCOUNT_ID, | ||
conversion_events = conversion_events, | ||
test = True, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
pin_id=DEFAULT_PIN_ID, | ||
name="Test_create_ad", | ||
status="ACTIVE", | ||
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change this to REGULAR for reasons explained above. |
||
pin_id=DEFAULT_PIN_ID, | ||
name="Test_create_ad", | ||
status="ACTIVE", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
Provide helper and utility functions for Organic Endpoints Integration Testing | ||
""" | ||
import random | ||
import logging | ||
|
||
from pinterest.client import PinterestSDKClient | ||
|
||
|
@@ -10,6 +11,7 @@ | |
|
||
from integration_tests.config import DEFAULT_BOARD_ID, DEFAULT_PIN_ID | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
def _merge_default_params_with_params(default_params, params): | ||
if not params: | ||
|
@@ -79,4 +81,7 @@ def create_new_pin(self, **kwargs): | |
return Pin.create(**_merge_default_params_with_params(self.get_default_params(), kwargs)) | ||
|
||
def delete_pin(self, pin_id): | ||
return Pin.delete(pin_id=pin_id, client=self.test_client) | ||
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) | ||
Comment on lines
+84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
else: | ||
log.warning(f"Default pin {DEFAULT_PIN_ID} was attempted to be deleted.") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change this for reasons explained above. |
||
|
||
from pinterest.ads.ad_groups import AdGroup | ||
from pinterest.ads.ads import Ad | ||
|
@@ -101,9 +102,7 @@ def test_update_ad_group(self, get_mock, update_mock): | |
""" | ||
update_mock.__name__ = "ad_groups_update" | ||
new_name = "SDK_AD_GROUP_NEW_NAME" | ||
new_spec = { | ||
"GENDER": ["male"] | ||
} | ||
new_spec = TargetingSpec(gender=["male"]) | ||
|
||
get_mock.return_value = AdGroupResponse( | ||
id=self.test_ad_group_id, | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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