Ejemplo n.º 1
0
 def test_internal_error(self):
     # pylint: disable=line-too-long
     code_client = mock_client(
         '{"errors": [{"code": "internal server error", "description": "sample text", "stacktrace": []}]}',
         codes.internal_server_error)
     self._assert_http_error(lambda: code_client.query("error"),
                             InternalError, "internal server error")
Ejemplo n.º 2
0
 def test_json_error(self):
     # Response must be valid JSON
     err = self.assert_raises(
         UnexpectedError, lambda: mock_client("I like fine wine").query(''))
     rr = err.request_result
     self.assertIsNone(rr.response_content)
     self.assertEqual(rr.response_raw, "I like fine wine")
Ejemplo n.º 3
0
 def test_unavailable_error(self):
     client = mock_client(
         '{"errors": [{"code": "unavailable", "description": "on vacation"}]}',
         codes.unavailable)
     self._assert_http_error(lambda: client.query(''), UnavailableError,
                             "unavailable")
Ejemplo n.º 4
0
 def test_unexpected_error_code(self):
     self.assertRaises(
         UnexpectedError,
         lambda: mock_client('{"errors": []}', 1337).query(''))
Ejemplo n.º 5
0
 def test_resource_error(self):
     # Response must have "resource"
     self.assertRaises(UnexpectedError,
                       lambda: mock_client('{"resoars": 1}').query(''))