예제 #1
0
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetCampaignAdExtensionService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        if self.__class__.campaign_id == '0':
            campaign_service = client.GetCampaignService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'name': 'Campaign #%s' % Utils.GetUniqueName(),
                    'status': 'PAUSED',
                    'biddingStrategy': {
                        'type': 'ManualCPC'
                    },
                    'budget': {
                        'period': 'DAILY',
                        'amount': {
                            'microAmount': '1000000'
                        },
                        'deliveryMethod': 'STANDARD'
                    }
                }
            }]
            self.__class__.campaign_id = \
                campaign_service.Mutate(operations)[0]['value'][0]['id']

        if not self.__class__.geo_location:
            geo_location_service = client.GetGeoLocationService(
                self.__class__.SERVER, self.__class__.VERSION)
            selector = {'addresses': [self.__class__.address]}
            self.__class__.geo_location = \
                geo_location_service.Get(selector)[0]
예제 #2
0
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetAdExtensionOverrideService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        if self.__class__.campaign_id == '0':
            campaign_service = client.GetCampaignService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'name': 'Campaign #%s' % Utils.GetUniqueName(),
                    'status': 'PAUSED',
                    'biddingStrategy': {
                        'type': 'ManualCPC'
                    },
                    'budget': {
                        'period': 'DAILY',
                        'amount': {
                            'microAmount': '1000000'
                        },
                        'deliveryMethod': 'STANDARD'
                    }
                }
            }]
            self.__class__.campaign_id = campaign_service.Mutate(
                operations)[0]['value'][0]['id']
            ad_group_service = client.GetAdGroupService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'campaignId': self.__class__.campaign_id,
                    'name': 'AdGroup #%s' % Utils.GetUniqueName(),
                    'status': 'ENABLED',
                    'bids': {
                        'type': 'ManualCPCAdGroupBids',
                        'keywordMaxCpc': {
                            'amount': {
                                'microAmount': '1000000'
                            }
                        }
                    }
                }
            }]
            ad_group_id = ad_group_service.Mutate(
                operations)[0]['value'][0]['id']
            ad_service = client.GetAdGroupAdService(self.__class__.SERVER,
                                                    self.__class__.VERSION,
                                                    HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'type': 'AdGroupAd',
                    'adGroupId': ad_group_id,
                    'ad': {
                        'type': 'TextAd',
                        'url': 'http://www.example.com',
                        'displayUrl': 'example.com',
                        'description1': 'Visit the Red Planet in style.',
                        'description2': 'Low-gravity fun for everyone!',
                        'headline': 'Luxury Cruise to Mars'
                    },
                    'status': 'ENABLED'
                }
            }]
            self.__class__.ad_id = ad_service.Mutate(
                operations)[0]['value'][0]['ad']['id']

        if not self.__class__.geo_location:
            geo_location_service = client.GetGeoLocationService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            selector = {'addresses': [self.__class__.address]}
            self.__class__.geo_location = geo_location_service.Get(selector)[0]

        if self.__class__.ad_extension_id == '0':
            campaign_ad_extension_service = client.GetCampaignAdExtensionService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'type': 'CampaignAdExtension',
                    'campaignId': self.__class__.campaign_id,
                    'adExtension': {
                        'type':
                        'LocationExtension',
                        'address':
                        self.__class__.geo_location['address'],
                        'geoPoint':
                        self.__class__.geo_location['geoPoint'],
                        'encodedLocation':
                        self.__class__.geo_location['encodedLocation'],
                        'source':
                        'ADWORDS_FRONTEND'
                    }
                }
            }]
            self.__class__.ad_extension_id = campaign_ad_extension_service.Mutate(
                operations)[0]['value'][0]['adExtension']['id']
 def setUp(self):
     """Prepare unittest."""
     print self.id()
     if not self.__class__.service:
         self.__class__.service = client.GetGeoLocationService(
             self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)