Example #1
0
class AdWordsClientServiceTest(unittest.TestCase):
    """Tests for retrieving SOAP services via AdWordsClient."""
    def setUp(self):
        """Prepare unittest."""
        self.client = AdWordsClient(
            headers={
                'oauth2credentials': 'credential!',
                'userAgent': 'USER AGENT',
                'developerToken': 'DEV TOKEN'
            })

    def testGetAlertService(self):
        """AlertService shouldn't be created as of v201409"""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                service = self.client.GetAlertService()

    def testGetAlertService_v201406(self):
        """AlertService should be created in v201406 or earlier."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAlertService(version='v201406')
            self.assertEquals('AlertService', service._service_name)

    def testGetBudgetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetBudgetService()
            self.assertEquals('BudgetService', service._service_name)

    def testGetAdGroupFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupFeedService()
            self.assertEquals('AdGroupFeedService', service._service_name)

    def testGetCampaignFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignFeedService()
            self.assertEquals('CampaignFeedService', service._service_name)

    def testGetCustomerFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCustomerFeedService()
            self.assertEquals('CustomerFeedService', service._service_name)

    def testGetFeedItemService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedItemService()
            self.assertEquals('FeedItemService', service._service_name)

    def testGetFeedMappingService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedMappingService()
            self.assertEquals('FeedMappingService', service._service_name)

    def testGetFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedService()
            self.assertEquals('FeedService', service._service_name)

    def testGetCampaignSharedSetService(self):
        """CampaignSharedSetService should be created after v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignSharedSetService()
            self.assertEquals('CampaignSharedSetService',
                              service._service_name)

    def testGetCampaignSharedSetService_v201402(self):
        """CampaignSharedSetService shouldn't be created in v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                self.client.GetCampaignSharedSetService(version='v201402')

    def testGetSharedSetService(self):
        """SharedSetService now available in both v201402 and v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedSetService(version='v201406')
            self.assertEquals('SharedSetService', service._service_name)

    def testGetSharedCriterionService_v201402(self):
        """SharedCriterionService shouldn't be created in v201402."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            with self.assertRaises(ValidationError):
                self.client.GetSharedCriterionService(version='v201402')

    def testGetSharedCriterionService_v201406(self):
        """SharedCriterionService should be created in v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService(version='v201406')
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetSharedCriterionService_v201406(self):
        """SharedCriterionService should be created in v201406."""
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService(version='v201406')
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetAdGroupBidModifierService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupBidModifierService()
            self.assertEquals('AdGroupBidModifierService',
                              service._service_name)

    def testGetOfflineConversionFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetOfflineConversionFeedService()
            self.assertEquals('OfflineConversionFeedService',
                              service._service_name)

    def testGetLabelService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetLabelService()
            self.assertEquals('LabelService', service._service_name)
class AdWordsClientServiceTest(unittest.TestCase):
    """Tests for retrieving SOAP services via AdWordsClient."""
    def setUp(self):
        """Prepare unittest."""
        self.client = AdWordsClient(headers={
            'authToken': ' ',
            'userAgent': ' ',
            'developerToken': ' '
        })

    def testGetBudgetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetBudgetService()
            self.assertEquals('BudgetService', service._service_name)

    def testGetInfoService_notAllowed(self):
        self.assertRaises(ValidationError,
                          self.client.GetInfoService,
                          version='v201302')

    def testGetInfoService_allowed(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetInfoService(version='v201209')
            self.assertEquals('InfoService', service._service_name)

    def testGetAdGroupFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupFeedService()
            self.assertEquals('AdGroupFeedService', service._service_name)

    def testGetCampaignFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignFeedService()
            self.assertEquals('CampaignFeedService', service._service_name)

    def testGetFeedItemService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedItemService()
            self.assertEquals('FeedItemService', service._service_name)

    def testGetFeedMappingService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedMappingService()
            self.assertEquals('FeedMappingService', service._service_name)

    def testGetFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedService()
            self.assertEquals('FeedService', service._service_name)

    def testGetCampaignSharedSetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignSharedSetService()
            self.assertEquals('CampaignSharedSetService',
                              service._service_name)

    def testGetSharedSetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedSetService()
            self.assertEquals('SharedSetService', service._service_name)

    def testGetSharedCriterionService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService()
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetAdGroupBidModifierService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupBidModifierService()
            self.assertEquals('AdGroupBidModifierService',
                              service._service_name)
class AdWordsClientServiceTest(unittest.TestCase):
    """Tests for retrieving SOAP services via AdWordsClient."""
    def setUp(self):
        """Prepare unittest."""
        self.client = AdWordsClient(
            headers={
                'authToken': 'AUTH TOKEN',
                'userAgent': 'USER AGENT',
                'developerToken': 'DEV TOKEN'
            })

    def testGetBudgetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetBudgetService()
            self.assertEquals('BudgetService', service._service_name)

    def testGetAdGroupFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupFeedService()
            self.assertEquals('AdGroupFeedService', service._service_name)

    def testGetCampaignFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignFeedService()
            self.assertEquals('CampaignFeedService', service._service_name)

    def testGetFeedItemService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedItemService()
            self.assertEquals('FeedItemService', service._service_name)

    def testGetFeedMappingService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedMappingService()
            self.assertEquals('FeedMappingService', service._service_name)

    def testGetFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetFeedService()
            self.assertEquals('FeedService', service._service_name)

    def testGetCampaignSharedSetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetCampaignSharedSetService()
            self.assertEquals('CampaignSharedSetService',
                              service._service_name)

    def testGetSharedSetService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedSetService()
            self.assertEquals('SharedSetService', service._service_name)

    def testGetSharedCriterionService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetSharedCriterionService()
            self.assertEquals('SharedCriterionService', service._service_name)

    def testGetAdGroupBidModifierService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetAdGroupBidModifierService()
            self.assertEquals('AdGroupBidModifierService',
                              service._service_name)

    def testGetOfflineConversionFeedService(self):
        with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
            service = self.client.GetOfflineConversionFeedService()
            self.assertEquals('OfflineConversionFeedService',
                              service._service_name)