def run(self):
     """Represent thread's activity."""
     selector = {'ids': []}
     AdWordsWebServiceTestV201008.responses.append(
         client.GetCampaignService(AdWordsWebServiceTestV201008.SERVER,
                                   AdWordsWebServiceTestV201008.VERSION,
                                   HTTP_PROXY).Get(selector))
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetCampaignCriterionService(
                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']
  def setUp(self):
    """Prepare unittest."""
    print self.id()
    if not self.__class__.service:
      self.__class__.service = client.GetCustomerSyncService(
          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'
              },
              'endDate': date(date.today().year + 1, 12, 31).strftime('%Y%m%d'),
              'budget': {
                  'period': 'DAILY',
                  'amount': {
                      'microAmount': '2000000'
                  },
                  'deliveryMethod': 'STANDARD'
              }
          }
      }]
      self.__class__.campaign_id = campaign_service.Mutate(
          operations)[0]['value'][0]['id']
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetReportDefinitionService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        if self.__class__.ad_group_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': {
                        'xsi_type': 'ManualCPC'
                    },
                    'budget': {
                        'period': 'DAILY',
                        'amount': {
                            'microAmount': '1000000'
                        },
                        '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': {
                        'xsi_type': 'ManualCPCAdGroupBids',
                        'keywordMaxCpc': {
                            'amount': {
                                'microAmount': '1000000'
                            }
                        }
                    }
                }
            }]
            ad_groups = ad_group_service.Mutate(operations)[0]['value']
            self.__class__.ad_group_id = ad_groups[0]['id']
 def testMissingBiddingStrategy(self):
   """Tests whether we can catch missing bidding strategy exception."""
   try:
     operations = [
         {
             'operator': 'ADD',
             'operand': {
                 'status': 'PAUSED',
                 'budget': {
                     'period': 'DAILY',
                     'amount': {
                         'microAmount': '1000000'
                     },
                     'deliveryMethod': 'STANDARD'
                 }
             }
         }
     ]
     client.GetCampaignService(self.__class__.SERVER, self.__class__.VERSION,
         HTTP_PROXY).Mutate(operations)
   except AdWordsRequestError, e:
     self.assertEqual(e.errors[0].type, self.__class__.TRIGGER_TYPE1)
     self.assertEqual(e.errors[0].fieldPath, self.__class__.TRIGGER_MSG1)
Beispiel #6
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': {
                        'xsi_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]
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetBidLandscapeService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        if self.__class__.ad_group_id == '0' or self.__class__.criterion_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'
                    }
                }
            }]
            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_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': 'mars cruise'
                    }
                }
            }]
            self.__class__.criterion_id = ad_group_criterion_service.Mutate(
                operations)[0]['value'][0]['criterion']['id']
Beispiel #8
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 == '0'
                or self.__class__.text_ad_id == '0'
                or self.__class__.criterion_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': {
                        'xsi_type': 'ManualCPC'
                    },
                    'endDate':
                    date(date.today().year + 1, 12, 31).strftime('%Y%m%d'),
                    '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': {
                        'xsi_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': {
                    'xsi_type': 'AdGroupAd',
                    'adGroupId': self.__class__.ad_group_id,
                    'ad': {
                        'xsi_type': 'TextAd',
                        'url': 'http://www.example.com',
                        'displayUrl': 'example.com',
                        'description1': 'Good deals, only {param2:} left',
                        'description2': 'Low prices under {param1:}!',
                        'headline': 'MacBook Pro Sale'
                    },
                    'status': 'ENABLED'
                }
            }]
            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': {
                    'xsi_type': 'BiddableAdGroupCriterion',
                    'adGroupId': self.__class__.ad_group_id,
                    'criterion': {
                        'xsi_type': 'Keyword',
                        'matchType': 'BROAD',
                        'text': 'macbook pro'
                    }
                }
            }]
            self.__class__.criterion_id = ad_group_criterion_service.Mutate(
                operations)[0]['value'][0]['criterion']['id']
Beispiel #9
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.GetBulkMutateJobService(
          self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

    if self.__class__.campaign_id == '0':
      operations = [
          {
              'operator': 'ADD',
              'operand': {
                  'name': 'Campaign #%s' % Utils.GetUniqueName(),
                  'status': 'PAUSED',
                  'biddingStrategy': {
                      'xsi_type': 'ManualCPC'
                  },
                  'endDate': date(date.today().year + 1,
                                  12, 31).strftime('%Y%m%d'),
                  'budget': {
                      'period': 'DAILY',
                      'amount': {
                          'microAmount': '1000000'
                      },
                      'deliveryMethod': 'STANDARD'
                  }
              }
          }
      ]
      service = client.GetCampaignService(
          self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
      self.__class__.campaign_id = service.Mutate(
          operations)[0]['value'][0]['id']

    if (self.__class__.ad_group_id1 == '0' or
        self.__class__.ad_group_id2 == '0'):
      operations = [
          {
              'operator': 'ADD',
              'operand': {
                  'xsi_type': 'AdGroup',
                  'campaignId': self.__class__.campaign_id,
                  'name': 'AdGroup #%s' % Utils.GetUniqueName(),
                  'status': 'ENABLED',
                  'bids': {
                      'xsi_type': 'ManualCPCAdGroupBids',
                      'keywordMaxCpc': {
                          'amount': {
                              'microAmount': '1000000'
                          }
                      }
                  }
              }
          },
          {
              'operator': 'ADD',
              'operand': {
                  'xsi_type': 'AdGroup',
                  'campaignId': self.__class__.campaign_id,
                  'name': 'AdGroup #%s' % Utils.GetUniqueName(),
                  'status': 'ENABLED',
                  'bids': {
                      'xsi_type': 'ManualCPCAdGroupBids',
                      'keywordMaxCpc': {
                          'amount': {
                              'microAmount': '1000000'
                          }
                      }
                  }
              }
          }
      ]
      service = client.GetAdGroupService(
          self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
      ad_groups = service.Mutate(operations)[0]['value']
      self.__class__.ad_group_id1 = ad_groups[0]['id']
      self.__class__.ad_group_id2 = ad_groups[1]['id']