mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 14:12:29 +00:00
PEP8
This commit is contained in:
parent
b55969d381
commit
76a0120d3e
@ -38,4 +38,3 @@ class NotificationHandler:
|
|||||||
notif = yield from queue.get_json(5)
|
notif = yield from queue.get_json(5)
|
||||||
ws.send_str(notif)
|
ws.send_str(notif)
|
||||||
return ws
|
return ws
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class NotificationQueue(asyncio.Queue):
|
|||||||
"""
|
"""
|
||||||
Queue returned by the notification manager.
|
Queue returned by the notification manager.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._first = True
|
self._first = True
|
||||||
|
@ -68,6 +68,7 @@ class Query:
|
|||||||
Return a websocket connected to the path
|
Return a websocket connected to the path
|
||||||
"""
|
"""
|
||||||
self._session = aiohttp.ClientSession()
|
self._session = aiohttp.ClientSession()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def go_request(future):
|
def go_request(future):
|
||||||
response = yield from self._session.ws_connect(self.get_url(path))
|
response = yield from self._session.ws_connect(self.get_url(path))
|
||||||
|
@ -145,7 +145,7 @@ def test_termination_callback(vm, async_run):
|
|||||||
vm._termination_callback(0)
|
vm._termination_callback(0)
|
||||||
assert vm.status == "stopped"
|
assert vm.status == "stopped"
|
||||||
|
|
||||||
async_run(queue.get(0)) # Ping
|
async_run(queue.get(0)) # Ping
|
||||||
|
|
||||||
(action, event, kwargs) = async_run(queue.get(0))
|
(action, event, kwargs) = async_run(queue.get(0))
|
||||||
assert action == "vm.stopped"
|
assert action == "vm.stopped"
|
||||||
@ -164,8 +164,7 @@ def test_termination_callback_error(vm, tmpdir, async_run):
|
|||||||
vm._termination_callback(1)
|
vm._termination_callback(1)
|
||||||
assert vm.status == "stopped"
|
assert vm.status == "stopped"
|
||||||
|
|
||||||
|
async_run(queue.get(0)) # Ping
|
||||||
async_run(queue.get(0)) # Ping
|
|
||||||
|
|
||||||
(action, event, kwargs) = queue.get_nowait()
|
(action, event, kwargs) = queue.get_nowait()
|
||||||
assert action == "vm.stopped"
|
assert action == "vm.stopped"
|
||||||
|
@ -69,7 +69,6 @@ def test_queue_json_meta(async_run):
|
|||||||
assert len(notifications._listeners) == 0
|
assert len(notifications._listeners) == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_queue_ping(async_run):
|
def test_queue_ping(async_run):
|
||||||
"""
|
"""
|
||||||
If we don't send a message during a long time (0.5 seconds)
|
If we don't send a message during a long time (0.5 seconds)
|
||||||
|
@ -262,7 +262,7 @@ def test_list_files(tmpdir, loop):
|
|||||||
def test_emit(async_run):
|
def test_emit(async_run):
|
||||||
|
|
||||||
with NotificationManager.instance().queue() as queue:
|
with NotificationManager.instance().queue() as queue:
|
||||||
(action, event, context) = async_run(queue.get(0.5)) # Ping
|
(action, event, context) = async_run(queue.get(0.5)) # Ping
|
||||||
|
|
||||||
project = Project(project_id=str(uuid4()))
|
project = Project(project_id=str(uuid4()))
|
||||||
project.emit("test", {})
|
project.emit("test", {})
|
||||||
|
@ -87,9 +87,8 @@ def test_start(loop, vm, async_run):
|
|||||||
process = MagicMock()
|
process = MagicMock()
|
||||||
process.returncode = None
|
process.returncode = None
|
||||||
|
|
||||||
|
|
||||||
with NotificationManager.instance().queue() as queue:
|
with NotificationManager.instance().queue() as queue:
|
||||||
async_run(queue.get(0)) # Ping
|
async_run(queue.get(0)) # Ping
|
||||||
|
|
||||||
with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
|
with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
|
||||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
|
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
|
||||||
@ -147,7 +146,6 @@ def test_start_0_6_1(loop, vm):
|
|||||||
assert vm.is_running()
|
assert vm.is_running()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_stop(loop, vm, async_run):
|
def test_stop(loop, vm, async_run):
|
||||||
process = MagicMock()
|
process = MagicMock()
|
||||||
|
|
||||||
@ -166,7 +164,6 @@ def test_stop(loop, vm, async_run):
|
|||||||
loop.run_until_complete(asyncio.async(vm.start()))
|
loop.run_until_complete(asyncio.async(vm.start()))
|
||||||
assert vm.is_running()
|
assert vm.is_running()
|
||||||
|
|
||||||
|
|
||||||
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
|
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
|
||||||
loop.run_until_complete(asyncio.async(vm.stop()))
|
loop.run_until_complete(asyncio.async(vm.stop()))
|
||||||
assert vm.is_running() is False
|
assert vm.is_running() is False
|
||||||
@ -176,8 +173,8 @@ def test_stop(loop, vm, async_run):
|
|||||||
else:
|
else:
|
||||||
process.terminate.assert_called_with()
|
process.terminate.assert_called_with()
|
||||||
|
|
||||||
async_run(queue.get(0)) # Ping
|
async_run(queue.get(0)) # Ping
|
||||||
async_run(queue.get(0)) # Started
|
async_run(queue.get(0)) # Started
|
||||||
|
|
||||||
(action, event, kwargs) = async_run(queue.get(0))
|
(action, event, kwargs) = async_run(queue.get(0))
|
||||||
assert action == "vm.stopped"
|
assert action == "vm.stopped"
|
||||||
|
Loading…
Reference in New Issue
Block a user