def testError502(self):
    """Test whether we can handle and report 502 errors."""
    buf = DfaSoapBuffer()

    html_code = Utils.ReadFile(os.path.join('..', 'data', 'http_error_502.html'))
    buf.write(html_code)

    if not buf.IsHandshakeComplete():
      data = buf.GetBufferAsStr()
    else:
      data = ''

    self.assertEqual(Utils.GetErrorFromHtml(data), self.__class__.TRIGGER_MSG)
Esempio n. 2
0
    def testError502(self):
        """Test whether we can handle and report 502 errors."""
        buf = DfaSoapBuffer()

        html_code = Utils.ReadFile(
            os.path.join('..', 'data', 'http_error_502.html'))
        buf.write(html_code)

        if not buf.IsHandshakeComplete():
            data = buf.GetBufferAsStr()
        else:
            data = ''

        self.assertEqual(Utils.GetErrorFromHtml(data),
                         self.__class__.TRIGGER_MSG)
Esempio n. 3
0
  def _RunTestWithBuffer(self, buffer_):
    """Tests error parsing using the given DfaSoapBuffer."""
    client = DfaClient(headers={
        'Username': '******',
        'Password': '******',
        'AuthToken': 'password'
    })

    with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
      service = client.GetSpotlightService()

    buffer_ = DfaSoapBuffer('1', True)
    buffer_.write(open(BUFFER_FILE_LOCATION).read())

    try:
      service._HandleLogsAndErrors(buffer_, '', '', {'data': 'datum'})
    except DfaApiError, e:
      self.assertEqual('That Activity Group Name or Tag String already exists.',
                       e.error_message)
      self.assertEqual(8304, e.code)
      self.assertEqual('Code 8304: That Activity Group Name or Tag String '
                       'already exists.', str(e))
  def _RunTestWithBuffer(self, buffer_):
    """Tests error parsing using the given DfaSoapBuffer."""
    client = DfaClient(headers={
                           'Username': '******',
                           'Password': '******',
                           'AuthToken': 'password',
                           'appName': 'APP NAME'
                       }, path='/tmp/')

    with mock.patch('adspygoogle.SOAPpy.WSDL.Proxy'):
      service = client.GetSpotlightService()

    buffer_ = DfaSoapBuffer('1', True)
    buffer_.write(open(BUFFER_FILE_LOCATION).read())

    try:
      service._HandleLogsAndErrors(buffer_, '', '', {'data': 'datum'})
    except DfaApiError, e:
      self.assertEqual('That Activity Group Name or Tag String already exists.',
                       e.error_message)
      self.assertEqual(8304, e.code)
      self.assertEqual('Code 8304: That Activity Group Name or Tag String '
                       'already exists.', str(e))