Example #1
0
def test_timeout_passed_to_fido():
    with patch('bravado.fido_client.fido.fetch') as fetch:
        fido_client = FidoClient()
        request_params = dict(url='http://foo.com/', timeout=1)
        fido_client.request(request_params, response_callback=None)
        assert fetch.call_args == call(
            'http://foo.com/?', body='', headers={}, method='GET', timeout=1)
Example #2
0
def test_no_timeouts_passed_to_fido():
    with patch('bravado.fido_client.fido.fetch') as fetch:
        fido_client = FidoClient()
        request_params = dict(url='http://foo.com/')
        fido_client.request(request_params)
        assert fetch.call_args == mock.call(
            'http://foo.com/?', body='', headers={}, method='GET')
Example #3
0
def test_connect_timeout_and_timeout_passed_to_fido():
    with patch("bravado.fido_client.fido.fetch") as fetch:
        fido_client = FidoClient()
        request_params = dict(url="http://foo.com/", connect_timeout=1, timeout=2)
        fido_client.request(request_params, response_callback=None)
        assert fetch.call_args == mock.call(
            "http://foo.com/?", body="", headers={}, method="GET", connect_timeout=1, timeout=2
        )
Example #4
0
def test_no_timeouts_passed_to_fido():
    with patch('bravado.fido_client.fido.fetch') as fetch:
        fido_client = FidoClient()
        request_params = dict(url='http://foo.com/')
        fido_client.request(request_params)
        assert fetch.call_args == mock.call('http://foo.com/?',
                                            body='',
                                            headers={},
                                            method='GET')
Example #5
0
def test_connect_timeout_passed_to_fido():
    with patch('bravado.fido_client.fido.fetch') as fetch:
        fido_client = FidoClient()
        request_params = dict(url='http://foo.com/', connect_timeout=1)
        fido_client.request(request_params, response_callback=None)
        assert fetch.call_args == call('http://foo.com/?',
                                       body='',
                                       headers={},
                                       method='GET',
                                       connect_timeout=1)
Example #6
0
    def test_multiple_requests_against_fido_client(self):
        port = get_hopefully_free_port()
        launch_threaded_http_server(port)

        client = FidoClient()

        request_one_params = {
            'method': 'GET',
            'headers': {},
            'url': "http://localhost:{0}/1".format(port),
            'params': {},
        }

        request_two_params = {
            'method': 'GET',
            'headers': {},
            'url': "http://localhost:{0}/2".format(port),
            'params': {},
        }

        eventual_one = client.request(request_one_params)
        eventual_two = client.request(request_two_params)
        resp_one = eventual_one.result(timeout=1)
        resp_two = eventual_two.result(timeout=1)

        self.assertEqual(resp_one.text, ROUTE_1_RESPONSE)
        self.assertEqual(resp_two.text, ROUTE_2_RESPONSE)