mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix tests to work with new version of aiohttp (>= 3.0)
This commit is contained in:
1 parent
9ae9209881
commit
ab8dc52ece
18 files changed
+218
-184
No files matched your search
@@ -340,13 +340,12 @@ def test_stop_capture(http_controller, tmpdir, project, compute, async_run):
|
||||
assert response.status == 201
|
||||
|
||||
|
||||
def test_pcap(http_controller, tmpdir, project, compute, loop):
|
||||
def test_pcap(http_controller, tmpdir, project, compute, async_run):
|
||||
|
||||
async def go(future):
|
||||
response = await aiohttp.request("GET", http_controller.get_url("/projects/{}/links/{}/pcap".format(project.id, link.id)))
|
||||
response.body = await response.content.read(5)
|
||||
response.close()
|
||||
future.set_result(response)
|
||||
async def go():
|
||||
async with aiohttp.request("GET", http_controller.get_url("/projects/{}/links/{}/pcap".format(project.id, link.id))) as response:
|
||||
response.body = await response.content.read(5)
|
||||
return response
|
||||
|
||||
link = Link(project)
|
||||
link._capture_file_name = "test"
|
||||
@@ -354,10 +353,7 @@ def test_pcap(http_controller, tmpdir, project, compute, loop):
|
||||
with open(link.capture_file_path, "w+") as f:
|
||||
f.write("hello")
|
||||
project._links = {link.id: link}
|
||||
|
||||
future = asyncio.Future()
|
||||
asyncio.ensure_future(go(future))
|
||||
response = loop.run_until_complete(future)
|
||||
response = async_run(asyncio.ensure_future(go()))
|
||||
assert response.status == 200
|
||||
assert b'hello' == response.body
|
||||
|
||||
|
||||
@@ -172,12 +172,11 @@ def test_notification(http_controller, project, controller, loop, async_run):
|
||||
|
||||
async def go():
|
||||
connector = aiohttp.TCPConnector()
|
||||
response = await aiohttp.request("GET", http_controller.get_url("/projects/{project_id}/notifications".format(project_id=project.id)), connector=connector)
|
||||
response.body = await response.content.read(200)
|
||||
controller.notification.project_emit("node.created", {"a": "b"})
|
||||
response.body += await response.content.readany()
|
||||
response.close()
|
||||
return response
|
||||
async with aiohttp.request("GET", http_controller.get_url("/projects/{project_id}/notifications".format(project_id=project.id)), connector=connector) as response:
|
||||
response.body = await response.content.read(200)
|
||||
controller.notification.project_emit("node.created", {"a": "b"})
|
||||
response.body += await response.content.readany()
|
||||
return response
|
||||
|
||||
response = async_run(asyncio.ensure_future(go()))
|
||||
assert response.status == 200
|
||||
@@ -205,7 +204,7 @@ def test_notification_ws(http_controller, controller, project, async_run):
|
||||
assert answer["action"] == "test"
|
||||
|
||||
async_run(http_controller.close())
|
||||
ws.close()
|
||||
async_run(ws.close())
|
||||
assert project.status == "opened"
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user