def run(self):
     """Represent thread's activity."""
     search_criteria = {'pageSize': '10'}
     DfaWebServiceTestV1_18.res.append(
         client.GetAdvertiserService(
             DfaWebServiceTestV1_18.SERVER, DfaWebServiceTestV1_18.VERSION,
             HTTP_PROXY).GetAdvertisers(search_criteria))
    def testUpperStackLogging(self):
        """Tests whether we can define logger at client level and log before and
    after the API request is made.
    """
        logger = logging.getLogger(self.__class__.__name__)
        logger.setLevel(logging.DEBUG)
        fh = logging.FileHandler(self.__class__.TMP_LOG)
        fh.setLevel(logging.DEBUG)
        logger.addHandler(fh)

        # Clean up temporary log file.
        Utils.PurgeLog(self.__class__.TMP_LOG)

        logger.debug(self.__class__.DEBUG_MSG1)
        advertiser_service = client.GetAdvertiserService(
            self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
        advertiser_service.GetAdvertisers({})
        logger.debug(self.__class__.DEBUG_MSG2)

        data = Utils.ReadFile(self.__class__.TMP_LOG)
        self.assertEqual(data.find(self.__class__.DEBUG_MSG1), 0)
        self.assertEqual(data.find(self.__class__.DEBUG_MSG2),
                         len(self.__class__.DEBUG_MSG1) + 1)

        # Clean up and remove temporary log file.
        Utils.PurgeLog(self.__class__.TMP_LOG)
        os.remove(self.__class__.TMP_LOG)
 def testCallMethod(self):
     """Test whether we can call an API method indirectly."""
     search_criteria = {'pageSize': '10'}
     self.assert_(
         isinstance(
             client.GetAdvertiserService(
                 self.__class__.SERVER, self.__class__.VERSION,
                 HTTP_PROXY).GetAdvertisers(search_criteria), tuple))
    def setUp(self):
        """Prepare unittest."""
        print self.id()
        if not self.__class__.service:
            self.__class__.service = client.GetChangeLogService(
                self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

        advertiser_service = client.GetAdvertiserService(
            self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
        search_criteria = {}
        self.__class__.advertiser_id = advertiser_service.GetAdvertisers(
            search_criteria)[0]['records'][0]['id']
Exemplo n.º 5
0
  def setUp(self):
    """Prepare unittest."""
    print self.id()
    if not self.__class__.service:
      self.__class__.service = client.GetCreativeFieldService(
          self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)

    if self.__class__.advertiser_id == '0':
      advertiser_service = client.GetAdvertiserService(
          self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)
      search_criteria = {}
      advertiser = advertiser_service.GetAdvertisers(
          search_criteria)[0]['records'][0]
      creative_field_search_criteria = {'advertiserIds': [advertiser['id']]}
      results = self.__class__.service.GetCreativeFields(
          creative_field_search_criteria)[0]
      if results['records']:
        for creative_field in results['records']:
          self.__class__.service.DeleteCreativeField(creative_field['id'])
      self.__class__.advertiser_id = advertiser['id']
Exemplo n.º 6
0
 def setUp(self):
     """Prepare unittest."""
     print self.id()
     if not self.__class__.service:
         self.__class__.service = client.GetAdvertiserService(
             self.__class__.SERVER, self.__class__.VERSION, HTTP_PROXY)