-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update version to v8 * updated objective names * update examples for new product names * added description field for TA * added tests for targeted audiences * add owner_account_id to test and resource
- Loading branch information
Showing
9 changed files
with
136 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"request": { | ||
"params": { | ||
"account_id": "2iqph", | ||
"tailored_audience_id": "abc2" | ||
} | ||
}, | ||
"next_cursor": null, | ||
"data": [ | ||
{ | ||
"campaign_id": "59hod", | ||
"campaign_name": "test-campaign", | ||
"line_items": [ | ||
{ | ||
"id": "5gzog", | ||
"name": "test-line-item", | ||
"servable": true | ||
} | ||
] | ||
}, | ||
{ | ||
"campaign_id": "arja7", | ||
"campaign_name": "Untitled campaign", | ||
"line_items": [ | ||
{ | ||
"id": "bjw1q", | ||
"name": null, | ||
"servable": true | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import responses | ||
import unittest | ||
|
||
from tests.support import with_resource, with_fixture, characters | ||
|
||
from twitter_ads.account import Account | ||
from twitter_ads.client import Client | ||
from twitter_ads.audience import TailoredAudience | ||
from twitter_ads.cursor import Cursor | ||
from twitter_ads import API_VERSION | ||
|
||
|
||
@responses.activate | ||
def test_targeted_audiences(): | ||
responses.add(responses.GET, | ||
with_resource('/' + API_VERSION + '/accounts/2iqph'), | ||
body=with_fixture('accounts_load')) | ||
|
||
responses.add(responses.GET, | ||
with_resource('/' + API_VERSION + '/accounts/2iqph/tailored_audiences/2906h'), | ||
body=with_fixture('tailored_audiences_load')) | ||
|
||
responses.add(responses.GET, | ||
with_resource('/' + API_VERSION + '/accounts/2iqph/tailored_audiences/abc2/targeted?with_active=True'), | ||
body=with_fixture('targeted_audiences')) | ||
|
||
client = Client( | ||
characters(40), | ||
characters(40), | ||
characters(40), | ||
characters(40) | ||
) | ||
|
||
account = Account.load(client, '2iqph') | ||
|
||
audience = TailoredAudience.load(account, '2906h') | ||
targeted_audiences = audience.targeted( | ||
with_active=True | ||
) | ||
|
||
assert isinstance(targeted_audiences, Cursor) | ||
assert isinstance(targeted_audiences.first.line_items, list) | ||
assert targeted_audiences.first.campaign_id == '59hod' | ||
assert targeted_audiences.first.line_items[0]['id'] == '5gzog' | ||
assert targeted_audiences.first.line_items[0]['name'] == 'test-line-item' | ||
assert targeted_audiences.first.line_items[0]['servable'] == True | ||
assert len(responses.calls) == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters