Example #1
0
 def test_reply_has_err_message(self):
   with mock.patch.object(self.tablet_conn, 'client', autospec=True) as mock_client:
     response = gorpc.GoRpcResponse()
     response.reply = {'Err': {'Message': 'bar'}}
     mock_client.call.return_value = response
     with self.assertRaisesRegexp(gorpc.AppError, "'bar', 'method'"):
       self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #2
0
 def test_reply_is_dict(self):
     with mock.patch.object(self.tablet_conn, 'client',
                            autospec=True) as mock_client:
         response = gorpc.GoRpcResponse()
         response.reply = {'foo': 'bar'}
         mock_client.call.return_value = response
         self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #3
0
 def test_reply_has_non_dict_err(self):
   with mock.patch.object(self.tablet_conn, 'client', autospec=True) as mock_client:
     response = gorpc.GoRpcResponse()
     response.reply = {'Err': 'foo'}
     mock_client.call.return_value = response
     with self.assertRaisesRegexp(gorpc.AppError, 'Missing error message'):
       self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #4
0
 def test_reply_has_non_dict_err(self):
     with mock.patch.object(self.tablet_conn, 'client',
                            autospec=True) as mock_client:
         response = gorpc.GoRpcResponse()
         response.reply = {'Err': 1}
         mock_client.call.return_value = response
         with self.assertRaisesRegexp(tablet.TabletError, 'UNKNOWN_ERROR'):
             self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #5
0
 def test_reply_has_err_code(self):
     with mock.patch.object(self.tablet_conn, 'client',
                            autospec=True) as mock_client:
         response = gorpc.GoRpcResponse()
         response.reply = {'Err': {'Code': vtrpc_pb2.TRANSIENT_ERROR}}
         mock_client.call.return_value = response
         with self.assertRaisesRegexp(tablet.TabletError,
                                      'TRANSIENT_ERROR'):
             self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #6
0
 def test_reply_is_none(self):
   with mock.patch.object(self.tablet_conn, 'client', autospec=True) as mock_client:
     mock_client.call.return_value = gorpc.GoRpcResponse()
     self.tablet_conn.rpc_call_and_extract_error('method', 'req')
Example #7
0
 def test_reply_is_string(self):
   response = gorpc.GoRpcResponse()
   response.reply = 'foo'
   vtgate_utils.extract_rpc_error('method', response)
Example #8
0
 def test_reply_is_none(self):
   vtgate_utils.extract_rpc_error('method', gorpc.GoRpcResponse())
Example #9
0
 def test_reply_is_empty_string(self):
   response = gorpc.GoRpcResponse()
   vtgate_utils.extract_rpc_error('method', response)
Example #10
0
 def test_reply_has_err_code(self):
   response = gorpc.GoRpcResponse()
   response.reply = {'Err': {'Code': vtrpc_pb2.TRANSIENT_ERROR}}
   with self.assertRaisesRegexp(vtgate_utils.VitessError,
       'TRANSIENT_ERROR'):
     vtgate_utils.extract_rpc_error('method', response)
Example #11
0
 def test_reply_has_err_message(self):
   response = gorpc.GoRpcResponse()
   response.reply = {'Err': {'Message': 'bar'}}
   with self.assertRaisesRegexp(vtgate_utils.VitessError,
       'UNKNOWN_ERROR.+bar'):
     vtgate_utils.extract_rpc_error('method', response)
Example #12
0
 def test_reply_has_missing_err_message(self):
   response = gorpc.GoRpcResponse()
   response.reply = {'Err': {'foo': 'bar'}}
   with self.assertRaisesRegexp(vtgate_utils.VitessError,
       'Missing error message'):
     vtgate_utils.extract_rpc_error('method', response)
Example #13
0
 def test_reply_has_non_dict_err(self):
   response = gorpc.GoRpcResponse()
   response.reply = {'Err': 1}
   with self.assertRaisesRegexp(vtgate_utils.VitessError, 'UNKNOWN_ERROR'):
     vtgate_utils.extract_rpc_error('method', response)
Example #14
0
 def test_reply_is_dict(self):
   response = gorpc.GoRpcResponse()
   response.reply = {'foo': 'bar'}
   vtgate_utils.extract_rpc_error('method', response)