Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import time
from elasticsearch2.transport import Transport, get_host_info
from elasticsearch2.connection import Connection
from elasticsearch2.connection_pool import DummyConnectionPool
from elasticsearch2.exceptions import ConnectionError, ImproperlyConfigured
from .test_cases import TestCase
class DummyConnection(Connection):
def __init__(self, **kwargs):
self.exception = kwargs.pop('exception', None)
self.status, self.data = kwargs.pop('status', 200), kwargs.pop('data', '{}')
self.headers = kwargs.pop('headers', {})
self.calls = []
super(DummyConnection, self).__init__(**kwargs)
def perform_request(self, *args, **kwargs):
self.calls.append((args, kwargs))
if self.exception:
raise self.exception
return self.status, self.headers, self.data
CLUSTER_NODES = '''{
"ok" : true,
"cluster_name" : "super_cluster",