Skip to content

Commit

Permalink
test[fix]: Pass parameters to aiohttp correctly
Browse files Browse the repository at this point in the history
Apparently the parameter passing in our `aiohttp` tests
were incorrect, and was depending on a `yarl` bug [1] that was fixed [2]
in `1.9.0`, and with this new yarl version, our tests started to fail.
This fix corrects the parameter passing, so we can use the latest `yarl`.

[1] aio-libs/yarl#723
[2] aio-libs/yarl#792

Signed-off-by: Ferenc Géczi <ferenc.geczi@ibm.com>
  • Loading branch information
Ferenc- committed May 15, 2023
1 parent cbe085e commit d673bf9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tests/frameworks/test_aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

class TestAiohttp(unittest.TestCase):

async def fetch(self, session, url, headers=None):
async def fetch(self, session, url, headers=None, params=None):
try:
async with session.get(url, headers=headers) as response:
async with session.get(url, headers=headers, params=params) as response:
return response
except aiohttp.web_exceptions.HTTPException:
pass
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_client_get_with_params_to_scrub(self):
async def test():
with async_tracer.start_active_span('test'):
async with aiohttp.ClientSession() as session:
return await self.fetch(session, testenv["wsgi_server"] + "/?secret=yeah")
return await self.fetch(session, testenv["wsgi_server"], params={"secret": "yeah"})

response = self.loop.run_until_complete(test())

Expand Down
8 changes: 4 additions & 4 deletions tests/frameworks/test_aiohttp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

class TestAiohttpServer(unittest.TestCase):

async def fetch(self, session, url, headers=None):
async def fetch(self, session, url, headers=None, params=None):
try:
async with session.get(url, headers=headers) as response:
async with session.get(url, headers=headers, params=params) as response:
return response
except aiohttp.web_exceptions.HTTPException:
pass
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_server_get_with_params_to_scrub(self):
async def test():
with async_tracer.start_active_span('test'):
async with aiohttp.ClientSession() as session:
return await self.fetch(session, testenv["aiohttp_server"] + "/?secret=iloveyou")
return await self.fetch(session, testenv["aiohttp_server"], params={"secret": "iloveyou"})

response = self.loop.run_until_complete(test())

Expand Down Expand Up @@ -254,7 +254,7 @@ async def test():
headers['X-Capture-This'] = 'this'
headers['X-Capture-That'] = 'that'

return await self.fetch(session, testenv["aiohttp_server"] + "/?secret=iloveyou", headers=headers)
return await self.fetch(session, testenv["aiohttp_server"], headers=headers, params={"secret": "iloveyou"})

response = self.loop.run_until_complete(test())

Expand Down
8 changes: 4 additions & 4 deletions tests/frameworks/test_tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@


class TestTornadoServer(unittest.TestCase):
async def fetch(self, session, url, headers=None):
async def fetch(self, session, url, headers=None, params=None):
try:
async with session.get(url, headers=headers) as response:
async with session.get(url, headers=headers, params=params) as response:
return response
except aiohttp.web_exceptions.HTTPException:
pass
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_get_with_params_to_scrub(self):
async def test():
with async_tracer.start_active_span('test'):
async with aiohttp.ClientSession() as session:
return await self.fetch(session, testenv["tornado_server"] + "/?secret=yeah")
return await self.fetch(session, testenv["tornado_server"], params={"secret": "yeah"})

response = tornado.ioloop.IOLoop.current().run_sync(test)

Expand Down Expand Up @@ -525,7 +525,7 @@ async def test():
headers['X-Capture-This'] = 'this'
headers['X-Capture-That'] = 'that'

return await self.fetch(session, testenv["tornado_server"] + "/?secret=iloveyou", headers=headers)
return await self.fetch(session, testenv["tornado_server"], headers=headers, params={"secret": "iloveyou"})

response = tornado.ioloop.IOLoop.current().run_sync(test)

Expand Down
1 change: 0 additions & 1 deletion tests/requirements-307.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ spyne>=2.14.0
tornado>=4.5.3,<6.0
uvicorn>=0.13.4
urllib3[secure]<1.27,>=1.26.5
yarl==1.8.2
1 change: 0 additions & 1 deletion tests/requirements-310-with-tornado.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ spyne>=2.14.0

uvicorn>=0.13.4
urllib3[secure]<1.27,>=1.26.5
yarl==1.8.2
1 change: 0 additions & 1 deletion tests/requirements-310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ spyne>=2.14.0

uvicorn>=0.13.4
urllib3[secure]<1.27,>=1.26.5
yarl==1.8.2
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ spyne>=2.14.0
tornado>=4.5.3,<6.0
uvicorn>=0.13.4
urllib3[secure]<1.27,>=1.26.5
yarl==1.8.2

0 comments on commit d673bf9

Please sign in to comment.