A notification stream with process monitoring

This commit is contained in:
Julien Duponchelle committed 2015-05-01 13:20:30 +02:00
1 parent 57f5e7a7d9
commit e9ec5c8a37
15 files changed
+256 -25

No files matched your search

+10
View File
@@ -72,6 +72,7 @@ def test_vm_invalid_vpcs_path(project, manager, loop):
def test_start(loop, vm):
process = MagicMock()
process.returncode = None
queue = vm.project.get_listen_queue()
with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
@@ -79,6 +80,9 @@ def test_start(loop, vm):
vm.port_add_nio_binding(0, nio)
loop.run_until_complete(asyncio.async(vm.start()))
assert vm.is_running()
(action, event) = queue.get_nowait()
assert action == "vm.started"
assert event == vm
def test_stop(loop, vm):
@@ -98,6 +102,8 @@ def test_stop(loop, vm):
loop.run_until_complete(asyncio.async(vm.start()))
assert vm.is_running()
queue = vm.project.get_listen_queue()
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
loop.run_until_complete(asyncio.async(vm.stop()))
assert vm.is_running() is False
@@ -107,6 +113,10 @@ def test_stop(loop, vm):
else:
process.terminate.assert_called_with()
(action, event) = queue.get_nowait()
assert action == "vm.stopped"
assert event == vm
def test_reload(loop, vm):
process = MagicMock()