Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
x = AsyncAWSAuthConnection('aws.vandelay.com',
http_client=Mock(name='client'))
Conn = x.get_http_connection = Mock(name='get_http_connection')
request = x.build_base_http_request('GET', 'foo', '/auth')
callback = PromiseMock(name='callback')
x._mexe(request, callback=callback)
Conn.return_value.request.assert_called_with(
request.method, request.path, request.body, request.headers,
)
Conn.return_value.getresponse.assert_called_with(
callback=callback,
)
no_callback_ret = x._mexe(request)
# _mexe always returns promise
assert isinstance(no_callback_ret, Thenable)
def test_getresponse(self):
client = Mock(name='client')
client.add_request = passthrough(name='client.add_request')
x = AsyncHTTPConnection('aws.vandelay.com', http_client=client)
x.Response = Mock(name='x.Response')
request = x.getresponse()
x.http_client.add_request.assert_called_with(request)
assert isinstance(request, Thenable)
assert isinstance(request.on_ready, Thenable)
response = Mock(name='Response')
request.on_ready(response)
x.Response.assert_called_with(response)
def test_getresponse(self):
client = Mock(name='client')
client.add_request = passthrough(name='client.add_request')
x = AsyncHTTPSConnection(http_client=client)
x.Response = Mock(name='x.Response')
request = x.getresponse()
x.http_client.add_request.assert_called_with(request)
assert isinstance(request, Thenable)
assert isinstance(request.on_ready, Thenable)
response = Mock(name='Response')
request.on_ready(response)
x.Response.assert_called_with(response)
def test_getresponse(self):
client = Mock(name='client')
client.add_request = passthrough(name='client.add_request')
x = AsyncHTTPSConnection(http_client=client)
x.Response = Mock(name='x.Response')
request = x.getresponse()
x.http_client.add_request.assert_called_with(request)
assert isinstance(request, Thenable)
assert isinstance(request.on_ready, Thenable)
response = Mock(name='Response')
request.on_ready(response)
x.Response.assert_called_with(response)