示例#1
0
 def testGetByName(self):
     adv = Advertiser(AdvertiserTest.conn)
     partner_id = '73qiy5s'
     advs = adv.find_by_name(partner_id, 'test')
     for result in advs:
         print result.get('AdvertiserName')
         assert result.get('AdvertiserName') == 'test'
示例#2
0
    def testGetByAdvertiser(self):
        # Create an advertiser first.
        adv = Advertiser(CampaignTest.conn)
        adv['AdvertiserName'] = 'test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        campaign = Campaign(CampaignTest.conn)
        campaign['AdvertiserId'] = adv.get('AdvertiserId')
        campaign['CampaignName'] = "test campaign"
        campaign['Budget'] = {'Amount': '10000.00', 'CurrencyCode': 'USD'}
        campaign['StartDate'] = '2015-02-01'
        campaign['CampaignConversionReportingColumns'] = []
        result = campaign.create()

        assert campaign.get('CampaignId') is not None

        loader = Campaign(CampaignTest.conn)
        campaign = loader.find(campaign.get('CampaignId'))
        assert campaign.get('CampaignName') == 'test campaign'

        campaigns = campaign.get_by_advertiser(adv.get('AdvertiserId'))
        for test_campaign in campaigns:
            assert test_campaign.get('CampaignId') == campaign.get('CampaignId')


        campaigns = campaign.get_by_name(test_campaign.get('AdvertiserId'), 'test campaign')
        for test_campaign in campaigns:
            assert test_campaign.get('CampaignName') == 'test campaign'
示例#3
0
 def testGetByPartner(self):
     adv = Advertiser(AdvertiserTest.conn)
     self.partner_id = 'acjf93j'
     advs = adv.find_by_partner(self.partner_id)
     advs = json.loads(advs).get("data").get("Result")
     for result in advs:
         assert result.get('AdvertiserId') is not None
示例#4
0
    def testCreate(self):

        # Create an advertiser first.
        adv = Advertiser(SiteListTest.conn)
        adv['AdvertiserName'] = 'site list adv test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        # Create an advertiser first.
        site_list = SiteList(SiteListTest.conn)
        site_list['SiteListName'] = 'testing site list'
        site_list['AdvertiserId'] = adv.get('AdvertiserId')
        domains = ["espn.com", "cnn.com", "accuenmedia.com"]
        site_list.set_domains(domains)

        site_list.create()

        assert site_list.get('SiteListId') is not None

        site_list.find_by_name(adv.get('AdvertiserId'), "testing site list")
示例#5
0
 def testGetByName(self):
     adv = Advertiser(AdvertiserTest.conn)
     partner_id = '73qiy5s'
     advs = adv.find_by_name(partner_id, 'test')
     for result in advs:
         print result.get('AdvertiserName')
         assert result.get('AdvertiserName') == 'test'
示例#6
0
    def testCreate(self):
        # Create an advertiser first.
        adv = Advertiser(CreativeTest.conn)
        adv['AdvertiserName'] = 'ad group adv test eman'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        adTag = """<script>
 document.write('<scr'+'ipt src=\'http://ad.doubleclick.net/adj/N8017.858336.OXEGENMEDIA.COM/B6940936;abr=!ie;sz=728x90;click=' + ('%%c1;cpdir=').replace(/;/g,'&') + ';ord=' + new Date().getTime() + '?\'></scr'+'ipt>');
</script>"""

        creative = Creative(CreativeTest.conn)
        creative['CreativeName'] = 'Creative Test'
        creative['AdvertiserId'] = adv.get('AdvertiserId')
        creative['ThirdPartyTagAttributes'] = {
            'AdTag': adTag,
            'Width': 300,
            'Height': 250,
            'LandingPageUrls': ['http://eman.com']
        }
        id = creative.create()

        loader = Creative(CreativeTest.conn)
        new_loaded = loader.find(creative.get('CreativeId'))
        assert new_loaded.get('CreativeId') == creative.get('CreativeId')

        assert new_loaded.get_size() == [300, 250]
示例#7
0
    def testCreate(self):

        # Create an advertiser first.
        adv = Advertiser(CampaignTest.conn)
        adv['AdvertiserName'] = 'test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        campaign = Campaign(CampaignTest.conn)
        campaign['AdvertiserId'] = adv.get('AdvertiserId')
        campaign['CampaignName'] = "test campaign"
        campaign['Budget'] = {'Amount': '10000.00', 'CurrencyCode': 'USD'}
        campaign['StartDate'] = '2015-02-01'
        campaign['CampaignConversionReportingColumns'] = []
        result = campaign.create()

        assert campaign.get('CampaignId') is not None

        loader = Campaign(CampaignTest.conn)
        campaign = loader.find(campaign.get('CampaignId'))
        assert campaign.get('CampaignName') == 'test campaign'
示例#8
0
    def testCreate(self):
        adv = Advertiser(AdvertiserTest.conn)
        adv['AdvertiserName'] = 'test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        assert adv.get('AdvertiserId') is not None

        loader = Advertiser(AdvertiserTest.conn)
        adv = loader.find(adv.get('AdvertiserId'))
        assert adv.get('AdvertiserName') == 'test'
示例#9
0
    def testCreate(self):

        # Create an advertiser first.
        adv = Advertiser(SiteListTest.conn)
        adv['AdvertiserName'] = 'site list adv test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        # Create an advertiser first.
        site_list = SiteList(SiteListTest.conn)
        site_list['SiteListName'] = 'testing site list'
        site_list['AdvertiserId'] = adv.get('AdvertiserId')
        domains = ["espn.com", "cnn.com", "accuenmedia.com"]
        site_list.set_domains(domains)

        site_list.create()

        assert site_list.get('SiteListId') is not None

        site_list.find_by_name(adv.get('AdvertiserId'), "testing site list")
示例#10
0
    def testCreate(self):
        adv = Advertiser(AdvertiserTest.conn)
        adv['AdvertiserName'] = 'test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        assert adv.get('AdvertiserId') is not None

        loader = Advertiser(AdvertiserTest.conn)
        adv = loader.find(adv.get('AdvertiserId'))
        assert adv.get('AdvertiserName') == 'test'
示例#11
0
    def testGetByCampaign(self):
        # Create an advertiser first.
        adv = Advertiser(AdGroupTest.conn)
        adv['AdvertiserName'] = 'ad group adv test'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()
        
        # Create a campaign first.
        campaign = Campaign(AdGroupTest.conn)
        campaign['AdvertiserId'] = adv.get('AdvertiserId')
        campaign['CampaignName'] = "test campaign for ad group"
        campaign['Budget'] = {'Amount': '10000.00', 'CurrencyCode': 'USD'}
        campaign['StartDate'] = '2015-02-01'
        campaign['CampaignConversionReportingColumns'] = []
        result = campaign.create()

        # Create an advertiser first.
        contract = Contract(AdGroupTest.conn)
        contract['Name'] = 'Contract Test'
        contract['OwnerPartnerId'] = '73qiy5s'
        contract["StartDateUtc"] = "2015-04-30T21:21:19.7668268"
        
        code = int(time.time())
        
        deals = [{
                "SupplyVendorId": 7, # AppNexus
                "SupplyVendorDealId": str(code), # AppNexus
                "FloorPriceCPM": {
                    "CurrencyCode": "USD",
                    "Amount": 1.0
                    }
                }]
        contract['Deals'] = deals
    
        contract.create()

        ad_group = AdGroup(AdGroupTest.conn)
        ad_group['CampaignId'] = campaign.get('CampaignId')
        ad_group['AdGroupName'] = 'ad group test'
        ad_group['IndustryCategoryId'] = 54
        attributes = {
            'BudgetSettings': {
                'Budget': {'Amount': 1000.00, 'CurrencyCode': 'USD'},
                'DailyBudget': {'Amount': 100.00, 'CurrencyCode': 'USD'},
                'PacingEnabled': True
                },
            'BaseBidCPM': {'Amount': 1.00, 'CurrencyCode': 'USD'},
            'MaxBidCPM': {'Amount': 2.00, 'CurrencyCode': 'USD'},
            'ContractTargeting': { 
                'InventoryTargetingType': 'BothMarkets',
                'ContractIds': [contract.get('ContractId')] 
                }
        }
        
        ad_group['RTBAttributes'] = attributes
        ad_group.set_domains(["espn.com", "cnn.com"])
        ad_group.create()

        ad_groups = ad_group.get_by_campaign(campaign.get('CampaignId'))
        for test_group in ad_groups:
            assert test_group.get('id') == ad_group.get('id')


        ad_groups = ad_group.get_by_name(campaign.get('CampaignId'), 'ad group test')
        for test_group in ad_groups:
            assert test_group.get('AdGroupName') == 'ad group test'
示例#12
0
    def testCreate(self):
        # Create an advertiser first.
        adv = Advertiser(AdGroupTest.conn)
        adv['AdvertiserName'] = 'ad group adv test eman'
        adv['AttributionClickLookbackWindowInSeconds'] = 3600
        adv['AttributionImpressionLookbackWindowInSeconds'] = 3600
        adv['ClickDedupWindowInSeconds'] = 7
        adv['ConversionDedupWindowInSeconds'] = 60
        adv['DefaultRightMediaOfferTypeId'] = 1  # Adult
        adv['IndustryCategoryId'] = 54  # Entertainment
        adv['PartnerId'] = '73qiy5s'
        adv.create()

        # Create a campaign first.
        campaign = Campaign(AdGroupTest.conn)
        campaign['AdvertiserId'] = adv.get('AdvertiserId')
        campaign['CampaignName'] = "test campaign for ad group"
        campaign['Budget'] = {'Amount': '10000.00', 'CurrencyCode': 'USD'}
        campaign['StartDate'] = '2015-02-01'
        campaign['CampaignConversionReportingColumns'] = []
        result = campaign.create()

        # Create an advertiser first.
        contract = Contract(AdGroupTest.conn)
        contract['Name'] = 'Contract Test'
        contract['OwnerPartnerId'] = '73qiy5s'
        contract["StartDateUtc"] = "2015-04-30T21:21:19.7668268"

        code = int(time.time())

        deals = [{
            "SupplyVendorId": 7,  # AppNexus
            "SupplyVendorDealId": str(code),  # AppNexus
            "FloorPriceCPM": {
                "CurrencyCode": "USD",
                "Amount": 1.0
            }
        }]
        contract['Deals'] = deals

        contract.create()

        ad_group = AdGroup(AdGroupTest.conn)
        ad_group['CampaignId'] = campaign.get('CampaignId')
        ad_group['AdGroupName'] = 'ad group test'
        ad_group['IndustryCategoryId'] = 54
        ad_group
        attributes = {
            'BudgetSettings': {
                'Budget': {
                    'Amount': 1000.00,
                    'CurrencyCode': 'USD'
                },
                'DailyBudget': {
                    'Amount': 100.00,
                    'CurrencyCode': 'USD'
                },
                'PacingEnabled': True
            },
            'BaseBidCPM': {
                'Amount': 1.00,
                'CurrencyCode': 'USD'
            },
            'MaxBidCPM': {
                'Amount': 2.00,
                'CurrencyCode': 'USD'
            },
        }

        ad_group['RTBAttributes'] = attributes
        ad_group.set_deals([contract.get('ContractId')])

        ad_group.create()

        assert ad_group.get('AdGroupId') is not None

        loader = AdGroup(AdGroupTest.conn)
        reloaded = loader.find(ad_group.get('AdGroupId'))
        assert ad_group.get('AdGroupId') == reloaded.get('AdGroupId')

        # test save
        reloaded.save()
示例#13
0
 def testGetByPartner(self):
     adv = Advertiser(AdvertiserTest.conn)
     partner_id = '73qiy5s'
     advs = adv.find_by_partner(partner_id)
     for result in advs:
         print result.get('AdvertiserId')
示例#14
0
 def testGetByName(self):
     adv = Advertiser(AdvertiserTest.conn)
     advs = adv.find_by_name(self.partner_id, 'Test SMP Api')
     advs = json.loads(advs).get("data").get("Result")
     for result in advs:
         assert result.get('AdvertiserName') == 'Test SMP Api'
示例#15
0
 def testGetByPartner(self):
     adv = Advertiser(AdvertiserTest.conn)
     partner_id = '73qiy5s'
     advs = adv.find_by_partner(partner_id)
     for result in advs:
         print result.get('AdvertiserId')