def test_t021_wad_Campaign_remove_noref_budgets(self): # this test checks if noref budgets are removed successfully using # Budget.removenorefbudgets ( ) client = adwords.AdWordsClient.LoadFromStorage() campaignnames = [ 'test_t021_campaign0', 'test_t021_campaign1', 'test_t021_campaign2' ] # create three campaigns with unspecified budgets, budgets are created # for them automatically c0 = Campaign.addcampaign(client, campaignnames[0]) c1 = Campaign.addcampaign(client, campaignnames[1]) c2 = Campaign.addcampaign(client, campaignnames[2]) # remove the campaigns, budgets are now 0 ref budgets Campaign.removecampaign(client, c0.campaignid) Campaign.removecampaign(client, c1.campaignid) Campaign.removecampaign(client, c2.campaignid) removedbudgets = Budget.removenorefbudgets(client) for budget in removedbudgets: print(budget.budgetname[11:]) self.assertTrue(budget.budgetname[11:] in campaignnames)
def test_t000_wad_Campaign_add_remove_usingaddremove(self): print('wad_Campaign test t000') client = adwords.AdWordsClient.LoadFromStorage() # creates three new campaigns campaign0id = Campaign.addcampaign(client, 'test_t000_campaign0').campaignid campaign1id = Campaign.addcampaign(client, 'test_t000_campaign1').campaignid campaign2id = Campaign.addcampaign(client, 'test_t000_campaign2').campaignid # gets the lists of all campaigns campaignlist = Campaign.listcampaigns(client) campaignidlist = [] # builds a list of campaigns with status != REMOVED for campaign in campaignlist: if campaign['status'] != Campaign.STATE_REMOVED: campaignidlist.append(campaign['id']) # asserts the campaigns added are in the list self.assertTrue(campaign0id in campaignidlist) self.assertTrue(campaign1id in campaignidlist) self.assertTrue(campaign2id in campaignidlist) # removes the campaigns Campaign.removecampaign(client, campaign0id) Campaign.removecampaign(client, campaign1id) Campaign.removecampaign(client, campaign2id) # gets the list of all campaigns campaignlist = Campaign.listcampaigns(client) campaignidlist = [] # builds a list of campaigns with status != REMOVED for campaign in campaignlist: if campaign['status'] != Campaign.STATE_REMOVED: campaignidlist.append(campaign['campaignId']) # asserts the campaigns added are not in the list self.assertFalse(campaign0id in campaignidlist) self.assertFalse(campaign1id in campaignidlist) self.assertFalse(campaign2id in campaignidlist) Budget.removenorefbudgets(client)
def test_t020_wad_Campaign_list_campaigns(self): client = adwords.AdWordsClient.LoadFromStorage() campaigns = Campaign.listcampaigns(client) rslt = Campaign._aw_addcampaign(client, 'test_t020_campaign0') #print ( rslt ) campaigns = Campaign.listcampaigns(client) Campaign.removecampaign(client, rslt['id']) rslt = Campaign.addcampaign(client, 'test_t020_campaign1') print(rslt) rslt = Campaign.removecampaign(client, rslt.campaignid) #print ( rslt ) Budget.removenorefbudgets(client)
def test_t001_wad_Campaign_sync_add_remove_usingaddremove(self): print('wad_Campaign test t001') client = adwords.AdWordsClient.LoadFromStorage() # sync with django db Campaign.sync(client) # beginning django campaigns queryset beginningcampaigns = Campaign.objects.all() # beginning awcampaignslst beginningawcampaignslst = Campaign.listcampaigns(client) # assert that the django campaign set and aw campaignset correspond self.assertEqual(len(beginningcampaigns), len(beginningawcampaignslst)) # create three new campaigns in aw campaign0id = Campaign.addcampaign(client, 'test_t001_campaign0').campaignid campaign1id = Campaign.addcampaign(client, 'test_t001_campaign1').campaignid campaign2id = Campaign.addcampaign(client, 'test_t001_campaign2').campaignid # sync with django db ###Campaign.sync ( client ) # test if the new campaigns added to aw are in the Django system self.assertEqual( len(beginningcampaigns) + 3, len(Campaign.objects.all())) self.assertEqual( len(beginningawcampaignslst) + 3, len(Campaign.objects.all())) self.assertTrue( Campaign.objects.filter( campaignname='test_t001_campaign0').exists()) self.assertTrue( Campaign.objects.filter( campaignname='test_t001_campaign1').exists()) self.assertTrue( Campaign.objects.filter( campaignname='test_t001_campaign2').exists()) # removes the campaigns from aw Campaign.removecampaign(client, campaign0id) Campaign.removecampaign(client, campaign1id) Campaign.removecampaign(client, campaign2id) # sync with django db ###Campaign.sync ( client ) # test if the django campaign set is equal to the aw campaign set after deletions self.assertEqual(len(beginningcampaigns), len(Campaign.objects.all())) self.assertEqual(len(beginningawcampaignslst), len(Campaign.objects.all())) self.assertFalse( Campaign.objects.filter( campaignname='test_t001_campaign0').exists()) self.assertFalse( Campaign.objects.filter( campaignname='test_t001_campaign1').exists()) self.assertFalse( Campaign.objects.filter( campaignname='test_t001_campaign2').exists()) Budget.removenorefbudgets(client)