Exemplo n.º 1
0
 def test_perform_request_debug(self, mock_log, mock_catch):
     mock_log.level = logging.DEBUG
     conn = ESHttpConnection()
     conn.pool = Mock()
     conn.pool.urlopen.return_value = Mock(
         data=six.b('foo'), status=200)
     conn.perform_request('POST', 'http://localhost:9200')
     mock_log.debug.assert_called_once_with(
         "('POST', 'http://localhost:9200')")
     conn.perform_request('POST', 'http://localhost:9200'*200)
     assert mock_catch.called
     assert mock_log.debug.call_count == 2
Exemplo n.º 2
0
 def test_perform_request_exception(self):
     conn = ESHttpConnection()
     conn.pool = Mock()
     conn.pool.urlopen.side_effect = TransportError('N/A', '')
     with pytest.raises(JHTTPBadRequest):
         conn.perform_request('POST', 'http://localhost:9200')