예제 #1
0
 def test_make_request(self, _):
     x = AsyncAWSAuthConnection('aws.vandelay.com',
                                http_client=Mock(name='client'))
     Conn = x.get_http_connection = Mock(name='get_http_connection')
     callback = PromiseMock(name='callback')
     ret = x.make_request('GET', '/foo', callback=callback)
     self.assertIs(ret, callback)
     Conn.return_value.request.assert_called()
     Conn.return_value.getresponse.assert_called_with(callback=callback, )
예제 #2
0
 def test_make_request(self, _):
     x = AsyncAWSAuthConnection('aws.vandelay.com',
                                http_client=Mock(name='client'))
     Conn = x.get_http_connection = Mock(name='get_http_connection')
     callback = PromiseMock(name='callback')
     ret = x.make_request('GET', '/foo', callback=callback)
     self.assertIs(ret, callback)
     self.assertTrue(Conn.return_value.request.called)
     Conn.return_value.getresponse.assert_called_with(
         callback=callback,
     )
예제 #3
0
 def test_mexe__with_sender(self, _):
     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')
     sender = Mock(name='sender')
     callback = PromiseMock(name='callback')
     x._mexe(request, sender=sender, callback=callback)
     sender.assert_called_with(
         Conn.return_value, request.method, request.path,
         request.body, request.headers, callback,
     )
예제 #4
0
 def test_mexe__with_sender(self, _):
     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')
     sender = Mock(name='sender')
     callback = PromiseMock(name='callback')
     x._mexe(request, sender=sender, callback=callback)
     sender.assert_called_with(
         Conn.return_value, request.method, request.path,
         request.body, request.headers, callback,
     )
예제 #5
0
    def test_mexe(self, _):
        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)