示例#1
0
"""

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

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

# Import appropriate classes from the client library.
from adspygoogle.adwords.AdWordsClient import AdWordsClient

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

# Initialize appropriate service.
alert_service = client.GetAlertService('https://adwords-sandbox.google.com',
                                       'v201008')

# Construct selector and get all alerts.
selector = {
    'query': {
        'clientSpec':
        'ALL',
        'filterSpec':
        'ALL',
        'types': [
            'ACCOUNT_BUDGET_BURN_RATE', 'ACCOUNT_BUDGET_ENDING',
            'ACCOUNT_ON_TARGET', 'CAMPAIGN_ENDED', 'CAMPAIGN_ENDING',
            'CREDIT_CARD_EXPIRING', 'DECLINED_PAYMENT',
            'KEYWORD_BELOW_MIN_CPC', 'MANAGER_LINK_PENDING',
            'MISSING_BANK_REFERENCE_NUMBER', 'PAYMENT_NOT_ENTERED',
            'TV_ACCOUNT_BUDGET_ENDING', 'TV_ACCOUNT_ON_TARGET',
示例#2
0
class AdWordsClientServiceTest(unittest.TestCase):
    """Tests for retrieving SOAP services via AdWordsClient."""
    def setUp(self):
        """Prepare unittest."""
        self.client = AdWordsClient(
            headers={
                'oauth2credentials': 'credential!',
                'userAgent': 'USER AGENT',
                'developerToken': 'DEV TOKEN'
            })

    def testGetAlertService(self):
        """AlertService shouldn't be created as of v201409"""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                service = self.client.GetAlertService()

    def testGetAlertService_v201406(self):
        """AlertService should be created in v201406 or earlier."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAlertService(version='v201406')
            self.assertEquals('AlertService', service._service_name)

    def testGetBudgetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetBudgetService()
            self.assertEquals('BudgetService', service._service_name)

    def testGetAdGroupFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupFeedService()
            self.assertEquals('AdGroupFeedService', service._service_name)

    def testGetCampaignFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignFeedService()
            self.assertEquals('CampaignFeedService', service._service_name)

    def testGetCustomerFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCustomerFeedService()
            self.assertEquals('CustomerFeedService', service._service_name)

    def testGetFeedItemService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedItemService()
            self.assertEquals('FeedItemService', service._service_name)

    def testGetFeedMappingService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedMappingService()
            self.assertEquals('FeedMappingService', service._service_name)

    def testGetFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedService()
            self.assertEquals('FeedService', service._service_name)

    def testGetCampaignSharedSetService(self):
        """CampaignSharedSetService should be created after v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignSharedSetService()
            self.assertEquals('CampaignSharedSetService',
                              service._service_name)

    def testGetCampaignSharedSetService_v201402(self):
        """CampaignSharedSetService shouldn't be created in v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                self.client.GetCampaignSharedSetService(version='v201402')

    def testGetSharedSetService(self):
        """SharedSetService now available in both v201402 and v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedSetService(version='v201406')
            self.assertEquals('SharedSetService', service._service_name)

    def testGetSharedCriterionService_v201402(self):
        """SharedCriterionService shouldn't be created in v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                self.client.GetSharedCriterionService(version='v201402')

    def testGetSharedCriterionService_v201406(self):
        """SharedCriterionService should be created in v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService(version='v201406')
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetSharedCriterionService_v201406(self):
        """SharedCriterionService should be created in v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService(version='v201406')
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetAdGroupBidModifierService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupBidModifierService()
            self.assertEquals('AdGroupBidModifierService',
                              service._service_name)

    def testGetOfflineConversionFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetOfflineConversionFeedService()
            self.assertEquals('OfflineConversionFeedService',
                              service._service_name)

    def testGetLabelService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetLabelService()
            self.assertEquals('LabelService', service._service_name)