Added timeout to available input query parameters (#210)
* Added timeout to available input query parameters Signed-off-by: Harsha Vamsi Kalluri <[email protected]> * Add unit test to ensure that timeout is an accepted parameter Signed-off-by: Harsha Vamsi Kalluri <[email protected]> Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
This commit is contained in:
@@ -455,6 +455,8 @@ class Transport(object):
|
||||
timeout = None
|
||||
if params:
|
||||
timeout = params.pop("request_timeout", None)
|
||||
if not timeout:
|
||||
timeout = params.pop("timeout", None)
|
||||
ignore = params.pop("ignore", ())
|
||||
if isinstance(ignore, int):
|
||||
ignore = (ignore,)
|
||||
|
||||
@@ -140,6 +140,18 @@ class TestTransport:
|
||||
"headers": None,
|
||||
} == t.get_connection().calls[0][1]
|
||||
|
||||
async def test_timeout_extracted_from_params_and_passed(self):
|
||||
t = AsyncTransport([{}], connection_class=DummyConnection)
|
||||
|
||||
await t.perform_request("GET", "/", params={"timeout": 84})
|
||||
assert 1 == len(t.get_connection().calls)
|
||||
assert ("GET", "/", {}, None) == t.get_connection().calls[0][0]
|
||||
assert {
|
||||
"timeout": 84,
|
||||
"ignore": (),
|
||||
"headers": None,
|
||||
} == t.get_connection().calls[0][1]
|
||||
|
||||
async def test_opaque_id(self):
|
||||
t = AsyncTransport([{}], opaque_id="app-1", connection_class=DummyConnection)
|
||||
|
||||
|
||||
@@ -142,6 +142,17 @@ class TestTransport(TestCase):
|
||||
t.get_connection().calls[0][1],
|
||||
)
|
||||
|
||||
def test_timeout_extracted_from_params_and_passed(self):
|
||||
t = Transport([{}], connection_class=DummyConnection)
|
||||
|
||||
t.perform_request("GET", "/", params={"timeout": 84})
|
||||
self.assertEqual(1, len(t.get_connection().calls))
|
||||
self.assertEqual(("GET", "/", {}, None), t.get_connection().calls[0][0])
|
||||
self.assertEqual(
|
||||
{"timeout": 84, "ignore": (), "headers": None},
|
||||
t.get_connection().calls[0][1],
|
||||
)
|
||||
|
||||
def test_opaque_id(self):
|
||||
t = Transport([{}], opaque_id="app-1", connection_class=DummyConnection)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user