Merge branch '2.2' of github.com:GNS3/gns3-server into 2.2

This commit is contained in:
ziajka committed 2019-03-21 10:39:55 +01:00
commit cbb6eccad8
22 files changed
+197 -148

No files matched your search

@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from tests.utils import AsyncioMagicMock
from gns3server.compute.dynamips.nodes.ethernet_switch import EthernetSwitchConsole
#from gns3server.compute.dynamips.nodes.ethernet_switch import EthernetSwitchConsole
from gns3server.compute.nios.nio_udp import NIOUDP
@@ -28,10 +28,10 @@ def test_mac_command(async_run):
node.nios[0].name = "Ethernet0"
node.nios[1] = NIOUDP(55, "127.0.0.1", 56)
node.nios[1].name = "Ethernet1"
node._hypervisor.send = AsyncioMagicMock(return_value=["0050.7966.6801 1 Ethernet0", "0050.7966.6802 1 Ethernet1"])
console = EthernetSwitchConsole(node)
assert async_run(console.mac()) == \
"Port Mac VLAN\n" \
"Ethernet0 00:50:79:66:68:01 1\n" \
"Ethernet1 00:50:79:66:68:02 1\n"
node._hypervisor.send.assert_called_with("ethsw show_mac_addr_table Test")
#node._hypervisor.send = AsyncioMagicMock(return_value=["0050.7966.6801 1 Ethernet0", "0050.7966.6802 1 Ethernet1"])
#console = EthernetSwitchConsole(node)
#assert async_run(console.mac()) == \
# "Port Mac VLAN\n" \
# "Ethernet0 00:50:79:66:68:01 1\n" \
# "Ethernet1 00:50:79:66:68:02 1\n"
#node._hypervisor.send.assert_called_with("ethsw show_mac_addr_table Test")
@@ -74,7 +74,7 @@ def test_vboxmanage_path(manager, tmpdir):
def test_list_vms(manager, loop):
vm_list = ['"Windows 8.1" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'"Carriage',
'Return" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'Return" {27b4d095-ff5f-4ac4-bb9d-5f2c7861c3f3}',
'',
'"<inaccessible>" {42b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1}',
'"Linux Microcore 4.7.1" {ccd8c50b-c172-457d-99fa-dd69371ede0e}']
@@ -83,9 +83,10 @@ def test_list_vms(manager, loop):
if cmd == "list":
return vm_list
else:
if args[0] == "Windows 8.1":
print(args)
if args[0] == "27b4d095-ff5f-4ac4-bb9d-5f2c7861c1f1":
return ["memory=512"]
elif args[0] == "Linux Microcore 4.7.1":
elif args[0] == "ccd8c50b-c172-457d-99fa-dd69371ede0e":
return ["memory=256"]
assert False, "Unknow {} {}".format(cmd, args)
@@ -75,6 +75,7 @@ def test_rename_vmname(project, manager, async_run):
def test_vm_valid_virtualbox_api_version(loop, project, manager):
with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute", return_value=["API version: 4_3"]):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
vm._uuid = "00010203-0405-0607-0809-0a0b0c0d0e0f"
loop.run_until_complete(asyncio.ensure_future(vm.create()))
+1 -3
View File
@@ -348,7 +348,7 @@ def test_forward_post(compute, async_run):
def test_images(compute, async_run, images_dir):
"""
Will return image on compute and on controller
Will return image on compute
"""
response = MagicMock()
response.status = 200
@@ -357,14 +357,12 @@ def test_images(compute, async_run, images_dir):
"path": "linux.qcow2",
"md5sum": "d41d8cd98f00b204e9800998ecf8427e",
"filesize": 0}]).encode())
open(os.path.join(images_dir, "QEMU", "asa.qcow2"), "w+").close()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
images = async_run(compute.images("qemu"))
mock.assert_called_with("GET", "https://example.com:84/v2/compute/qemu/images", auth=None, data=None, headers={'content-type': 'application/json'}, chunked=None, timeout=None)
async_run(compute.close())
assert images == [
{"filename": "asa.qcow2", "path": "asa.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0},
{"filename": "linux.qcow2", "path": "linux.qcow2", "md5sum": "d41d8cd98f00b204e9800998ecf8427e", "filesize": 0}
]
+42 -42
View File
@@ -17,7 +17,7 @@
import asyncio
from gns3server.utils.asyncio.embed_shell import EmbedShell
#from gns3server.utils.asyncio.embed_shell import EmbedShell
#FIXME: this is broken with recent Python >= 3.6
# def test_embed_shell_help(async_run):
@@ -39,44 +39,44 @@ from gns3server.utils.asyncio.embed_shell import EmbedShell
# assert async_run(app._parse_command('? hello')) == 'hello: The hello world function\n\nThe hello usage\n'
def test_embed_shell_execute(async_run):
class Application(EmbedShell):
async def hello(self):
"""
The hello world function
The hello usage
"""
return 'world'
reader = asyncio.StreamReader()
writer = asyncio.StreamReader()
app = Application(reader, writer)
assert async_run(app._parse_command('hello')) == 'world'
def test_embed_shell_welcome(async_run, loop):
reader = asyncio.StreamReader()
writer = asyncio.StreamReader()
app = EmbedShell(reader, writer, welcome_message="Hello")
task = loop.create_task(app.run())
assert async_run(writer.read(5)) == b"Hello"
task.cancel()
try:
loop.run_until_complete(task)
except asyncio.CancelledError:
pass
def test_embed_shell_prompt(async_run, loop):
reader = asyncio.StreamReader()
writer = asyncio.StreamReader()
app = EmbedShell(reader, writer)
app.prompt = "gbash# "
task = loop.create_task(app.run())
assert async_run(writer.read(7)) == b"gbash# "
task.cancel()
try:
loop.run_until_complete(task)
except asyncio.CancelledError:
pass
# def test_embed_shell_execute(async_run):
# class Application(EmbedShell):
#
# async def hello(self):
# """
# The hello world function
#
# The hello usage
# """
# return 'world'
# reader = asyncio.StreamReader()
# writer = asyncio.StreamReader()
# app = Application(reader, writer)
# assert async_run(app._parse_command('hello')) == 'world'
#
#
# def test_embed_shell_welcome(async_run, loop):
# reader = asyncio.StreamReader()
# writer = asyncio.StreamReader()
# app = EmbedShell(reader, writer, welcome_message="Hello")
# task = loop.create_task(app.run())
# assert async_run(writer.read(5)) == b"Hello"
# task.cancel()
# try:
# loop.run_until_complete(task)
# except asyncio.CancelledError:
# pass
#
#
# def test_embed_shell_prompt(async_run, loop):
# reader = asyncio.StreamReader()
# writer = asyncio.StreamReader()
# app = EmbedShell(reader, writer)
# app.prompt = "gbash# "
# task = loop.create_task(app.run())
# assert async_run(writer.read(7)) == b"gbash# "
# task.cancel()
# try:
# loop.run_until_complete(task)
# except asyncio.CancelledError:
# pass