Adding a third return value from connection.perform_request - headers

This will be used to implement deserializing based on mimetype
This commit is contained in:
Honza Král
2013-12-13 19:36:21 +01:00
parent be9acfad90
commit e2ab7ea80d
8 changed files with 13 additions and 13 deletions
+2 -2
View File
@@ -62,7 +62,7 @@ class TestRequestsConnection(TestCase):
return con
def _get_request(self, connection, *args, **kwargs):
status, data = connection.perform_request(*args, **kwargs)
status, headers, data = connection.perform_request(*args, **kwargs)
self.assertEquals(200, status)
self.assertEquals(u'{}', data)
@@ -129,7 +129,7 @@ class TestRequestsConnection(TestCase):
@patch('elasticsearch.connection.base.logger')
def test_success_logs_and_traces(self, logger, tracer):
con = self._get_mock_connection(response_body='''{"answer": "that's it!"}''')
status, data = con.perform_request('GET', '/', {'param': 42}, '''{"question": "what's that?"}''')
status, headers, data = con.perform_request('GET', '/', {'param': 42}, '''{"question": "what's that?"}''')
# trace request
self.assertEquals(1, tracer.info.call_count)
+2 -1
View File
@@ -11,6 +11,7 @@ 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)
@@ -18,7 +19,7 @@ class DummyConnection(Connection):
self.calls.append((args, kwargs))
if self.exception:
raise self.exception
return self.status, self.data
return self.status, self.headers, self.data
CLUSTER_NODES = '''{
"ok" : true,