Ejemplo n.º 1
0
    def testGetByCampaign(self):
        loader = AdGroup(AdGroupTest.conn)
        ad_groups = loader.get_by_campaign(self.campaign_id)
        ad_groups = json.loads(ad_groups).get("data").get("Result")
        for test_group in ad_groups:
            assert test_group.get('AdGroupId') is not None

        ad_group_name = 'Test SMP API Ad Group'
        ad_groups = loader.get_by_name(self.campaign_id, ad_group_name)
        ad_groups = json.loads(ad_groups).get("data").get("Result")
        for test_group in ad_groups:
            assert test_group.get('AdGroupName') == 'Test SMP API Ad Group'
Ejemplo n.º 2
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'
Ejemplo n.º 3
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'