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)
예제 #2
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))
예제 #4
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)
예제 #5
0
 def testParseError_ETree_PrettyOff(self):
     """Tests that the SOAP buffer parses DFA errors correctly."""
     self._RunTestWithBuffer(DfaSoapBuffer('2', False))
예제 #6
0
 def testParseError_PyXML_PrettyOn(self):
     """Tests that the SOAP buffer parses DFA errors correctly."""
     self._RunTestWithBuffer(DfaSoapBuffer('1', True))