1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00

Test link.updated event

This commit is contained in:
Julien Duponchelle 2016-05-18 21:28:37 +02:00
parent 54747ee618
commit b00a09efaa
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 21 additions and 1 deletions

View File

@ -99,7 +99,6 @@ class Link:
self._capturing = False
self._project.controller.notification.emit("link.updated", self.__json__())
@asyncio.coroutine
def read_pcap_from_source(self):
"""

View File

@ -117,3 +117,24 @@ def test_default_capture_file_name(project, compute, async_run):
async_run(link.add_node(node1, 0, 4))
async_run(link.add_node(node2, 1, 3))
assert link.default_capture_file_name() == "Hello_0-4_to_w0rld_1-3.pcap"
def test_start_capture(link, async_run, tmpdir, project, controller):
@asyncio.coroutine
def fake_reader():
return AsyncioBytesIO()
link.read_pcap_from_source = fake_reader
controller._notification = MagicMock()
async_run(link.start_capture(capture_file_name="test.pcap"))
assert link._capturing
assert link._capture_file_name == "test.pcap"
controller._notification.emit.assert_called_with("link.updated", link.__json__())
def test_stop_capture(link, async_run, tmpdir, project, controller):
link._capturing = True
controller._notification = MagicMock()
async_run(link.stop_capture())
assert link._capturing is False
controller._notification.emit.assert_called_with("link.updated", link.__json__())