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

        if self.__class__.campaign_id is '0' or self.__class__.ad_group_id is '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'
                            }
                        }
                    }
                }
            }]
            self.__class__.ad_group_id = ad_group_service.Mutate(
                operations)[0]['value'][0]['id']
    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 is '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',
                        'status': 'ENABLED',
                        'description1': 'Visit the Red Planet in style.',
                        'description2': 'Low-gravity fun for everyone!',
                        'headline': 'Luxury Cruise to Mars'
                    }
                }
            }]
            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 is '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']
Beispiel #3
0
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetAdParamService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        if (self.__class__.ad_group_id is '0'
                or self.__class__.text_ad_id is '0'
                or self.__class__.criterion_id is '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'
                    },
                    'endDate': '20110101',
                    'budget': {
                        'period': 'DAILY',
                        'amount': {
                            'microAmount': '2000000'
                        },
                        'deliveryMethod': 'STANDARD'
                    }
                }
            }]
            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': campaign_id,
                    'name': 'AdGroup #%s' % Utils.GetUniqueName(),
                    'status': 'ENABLED',
                    'bids': {
                        'type': 'ManualCPCAdGroupBids',
                        'keywordMaxCpc': {
                            'amount': {
                                'microAmount': '1000000'
                            }
                        }
                    }
                }
            }]
            self.__class__.ad_group_id = \
                ad_group_service.Mutate(operations)[0]['value'][0]['id']
            ad_group_ad_service = client.GetAdGroupAdService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'type': 'AdGroupAd',
                    'adGroupId': self.__class__.ad_group_id,
                    'ad': {
                        'type': 'TextAd',
                        'url': 'http://www.example.com',
                        'displayUrl': 'example.com',
                        'status': 'ENABLED',
                        'description1': 'Good deals, only {param2:} left',
                        'description2': 'Low prices under {param1:}!',
                        'headline': 'MacBook Pro Sale'
                    }
                }
            }]
            self.__class__.text_ad_id = \
                ad_group_ad_service.Mutate(operations)[0]['value'][0]['ad']['id']
            ad_group_criterion_service = \
                client.GetAdGroupCriterionService(
                    self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
            operations = [{
                'operator': 'ADD',
                'operand': {
                    'type': 'BiddableAdGroupCriterion',
                    'adGroupId': self.__class__.ad_group_id,
                    'criterion': {
                        'type': 'Keyword',
                        'matchType': 'BROAD',
                        'text': 'macbook pro'
                    }
                }
            }]
            self.__class__.criterion_id = ad_group_criterion_service.Mutate(
                operations)[0]['value'][0]['criterion']['id']