예제 #1
0
class ErrorsTestV13(unittest.TestCase):
    """Unittest suite for Errors using v13."""

    SERVER = SERVER_V13
    VERSION = VERSION_V13
    TRIGGER_MSG1 = 'The developer token is invalid.'
    TRIGGER_CODE1 = 42
    TRIGGER_MSG2 = 'Login with this username/password failed.'
    TRIGGER_CODE2 = 9
    dummy_client = Client(path='..',
                          headers={
                              'email': 'xxxxxx',
                              'password': '******',
                              'useragent': 'ErrorsTest',
                              'developerToken': 'xxxxxx++USD'
                          })
    dummy_client.debug = False

    def setUp(self):
        """Prepare unittest."""
        print self.id()
        self.__class__.dummy_client.use_mcc = True

    def tearDown(self):
        """Finalize unittest."""
        self.__class__.dummy_client.use_mcc = False

    def testApiError(self):
        """Tests whether we can catch an Errors.ApiError exception."""
        try:
            self.__class__.dummy_client.GetAccountService(
                self.__class__.SERVER, self.__class__.VERSION,
                HTTP_PROXY).GetAccountInfo()
        except ApiError, e:
            try:
                self.assertEqual(e.message, self.__class__.TRIGGER_MSG1)
                self.assertEqual(e.code, self.__class__.TRIGGER_CODE1)
            except:
                self.assertEqual(e.message, self.__class__.TRIGGER_MSG2)
                self.assertEqual(e.code, self.__class__.TRIGGER_CODE2)
예제 #2
0
# Locate the client library. If module was installed via "setup.py" script, then
# the following two lines are not needed.
import sys
sys.path.append('../..')

# Import appropriate constants and classes from the client library.
from aw_api import LIB_HOME
from aw_api import MIN_API_VERSION
from aw_api import Utils
from aw_api.Client import Client
from aw_api.Errors import ApiError

# Initialize Client object. The "path" parameter should point to the location of
# pickles, which get generated after execution of "aw_api_config.py" script. The
# same location is used for the "logs/" directory, if logging is enabled.
client = Client(path='../..')

# Temporarily disable debugging. If enabled, the debugging data will be send to
# STDOUT.
client.debug = False

# Construct SOAP message by loading XML from existing data file.
soap_message = Utils.ReadFile(
    os.path.join(LIB_HOME, 'data', 'request_getaccountinfo.xml'))
url = '/api/adwords/%s/AccountService' % MIN_API_VERSION
http_proxy = None

try:
    response = client.CallRawMethod(soap_message, url, http_proxy)[0]

    # Display results.
예제 #3
0
Tags: BidLandscapeService.getBidLandscape
"""

__author__ = '[email protected] (Stan Grinberg)'

import os
import sys

sys.path.append(os.path.join('..', '..'))

# Import appropriate classes from the client library.
from aw_api.Client import Client

# Initialize client object.
client = Client(path=os.path.join('..', '..'))

# Initialize appropriate service.
bid_landscape_service = client.GetBidLandscapeService(
    'https://adwords-sandbox.google.com', 'v201003')

ad_group_id = 'INSERT_AD_GROUP_ID_HERE'
criterion_id = 'INSERT_CRITERION_ID_HERE'

# Construct bid landscape selector object and retrieve bid landscape.
selector = {
    'type': 'CriterionBidLandscapeSelector',
    'idFilters': [{
        'adGroupId': ad_group_id,
        'criterionId': criterion_id
    }]