1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Test pcap streaming

This commit is contained in:
Julien Duponchelle 2016-09-02 11:20:59 +02:00
parent 947dcf1406
commit be0fee99e7
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -182,15 +182,26 @@ def test_stop_capture(http_controller, tmpdir, project, compute, async_run):
assert response.status == 201
def test_pcap(http_controller, tmpdir, project, compute, async_run):
def test_pcap(http_controller, tmpdir, project, compute, loop):
@asyncio.coroutine
def go(future):
response = yield from aiohttp.request("GET", http_controller.get_url("/projects/{}/links/{}/pcap".format(project.id, link.id)))
response.body = yield from response.content.read(5)
response.close()
future.set_result(response)
link = Link(project)
link._capture_file_name = "test"
link._capturing = True
with open(link.capture_file_path, "w+") as f:
f.write("hello")
project._links = {link.id: link}
response = http_controller.get("/projects/{}/links/{}/pcap".format(project.id, link.id), example=False)
assert response.body == b"hello"
future = asyncio.Future()
asyncio.async(go(future))
response = loop.run_until_complete(future)
assert response.status == 200
assert b'hello' == response.body
def test_delete_link(http_controller, tmpdir, project, compute, async_run):