mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch '2.0' into 2.1
This commit is contained in:
37 files changed
+435
-70
No files matched your search
@@ -47,7 +47,7 @@ def test_query_success(loop, vm):
|
||||
vm._session.request = AsyncioMagicMock(return_value=response)
|
||||
data = loop.run_until_complete(asyncio.async(vm.query("POST", "test", data={"a": True}, params={"b": 1})))
|
||||
vm._session.request.assert_called_with('POST',
|
||||
'http://docker/test',
|
||||
'http://docker/v1.25/test',
|
||||
data='{"a": true}',
|
||||
headers={'content-type': 'application/json'},
|
||||
params={'b': 1},
|
||||
@@ -70,7 +70,7 @@ def test_query_error(loop, vm):
|
||||
with pytest.raises(DockerError):
|
||||
data = loop.run_until_complete(asyncio.async(vm.query("POST", "test", data={"a": True}, params={"b": 1})))
|
||||
vm._session.request.assert_called_with('POST',
|
||||
'http://docker/test',
|
||||
'http://docker/v1.25/test',
|
||||
data='{"a": true}',
|
||||
headers={'content-type': 'application/json'},
|
||||
params={'b': 1},
|
||||
@@ -91,7 +91,7 @@ def test_query_error_json(loop, vm):
|
||||
with pytest.raises(DockerError):
|
||||
data = loop.run_until_complete(asyncio.async(vm.query("POST", "test", data={"a": True}, params={"b": 1})))
|
||||
vm._session.request.assert_called_with('POST',
|
||||
'http://docker/test',
|
||||
'http://docker/v1.25/test',
|
||||
data='{"a": true}',
|
||||
headers={'content-type': 'application/json'},
|
||||
params={'b': 1},
|
||||
|
||||
@@ -154,6 +154,7 @@ def test_termination_callback(vm, async_run):
|
||||
assert event == vm
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
def test_termination_callback_error(vm, tmpdir, async_run):
|
||||
|
||||
with open(str(tmpdir / "qemu.log"), "w+") as f:
|
||||
|
||||
@@ -219,18 +219,6 @@ def test_get_relative_image_path(qemu, tmpdir, config):
|
||||
assert qemu.get_relative_image_path(path5) == path5
|
||||
|
||||
|
||||
def test_get_relative_image_path_ova(qemu, tmpdir, config):
|
||||
os.makedirs(str(tmpdir / "QEMU" / "test.ova"))
|
||||
path = str(tmpdir / "QEMU" / "test.ova" / "test.bin")
|
||||
open(path, 'w+').close()
|
||||
|
||||
config.set_section_config("Server", {
|
||||
"images_path": str(tmpdir)
|
||||
})
|
||||
assert qemu.get_relative_image_path(path) == os.path.join("test.ova", "test.bin")
|
||||
assert qemu.get_relative_image_path(os.path.join("test.ova", "test.bin")) == os.path.join("test.ova", "test.bin")
|
||||
|
||||
|
||||
def test_list_images(loop, qemu, tmpdir):
|
||||
|
||||
fake_images = ["a.qcow2", "b.qcow2", ".blu.qcow2", "a.qcow2.md5sum"]
|
||||
@@ -262,7 +250,7 @@ def test_list_images_recursives(loop, qemu, tmpdir):
|
||||
assert loop.run_until_complete(qemu.list_images()) == [
|
||||
{"filename": "a.qcow2", "path": "a.qcow2", "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1},
|
||||
{"filename": "b.qcow2", "path": "b.qcow2", "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1},
|
||||
{"filename": "c.qcow2", "path": os.path.sep.join(["c", "c.qcow2"]), "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1}
|
||||
{"filename": "c.qcow2", "path": force_unix_path(os.path.sep.join(["c", "c.qcow2"])), "md5sum": "c4ca4238a0b923820dcc509a6f75849b", "filesize": 1}
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ def test_import_iou_linux_no_vm(linux_platform, async_run, tmpdir, controller):
|
||||
{
|
||||
"compute_id": "local",
|
||||
"node_type": "iou",
|
||||
"name": "test",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
@@ -224,6 +225,7 @@ def test_import_iou_linux_with_vm(linux_platform, async_run, tmpdir, controller)
|
||||
"compute_id": "local",
|
||||
"node_id": "0fd3dd4d-dc93-4a04-a9b9-7396a9e22e8b",
|
||||
"node_type": "iou",
|
||||
"name": "test",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
@@ -267,11 +269,13 @@ def test_import_iou_non_linux(windows_platform, async_run, tmpdir, controller):
|
||||
"compute_id": "local",
|
||||
"node_id": "0fd3dd4d-dc93-4a04-a9b9-7396a9e22e8b",
|
||||
"node_type": "iou",
|
||||
"name": "test",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"compute_id": "local",
|
||||
"node_type": "vpcs",
|
||||
"name": "test2",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
@@ -319,12 +323,14 @@ def test_import_node_id(linux_platform, async_run, tmpdir, controller):
|
||||
"compute_id": "local",
|
||||
"node_id": "0fd3dd4d-dc93-4a04-a9b9-7396a9e22e8b",
|
||||
"node_type": "iou",
|
||||
"name": "test",
|
||||
"properties": {}
|
||||
},
|
||||
{
|
||||
"compute_id": "local",
|
||||
"node_id": "c3ae286c-c81f-40d9-a2d0-5874b2f2478d",
|
||||
"node_type": "iou",
|
||||
"name": "test2",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
@@ -409,6 +415,7 @@ def test_import_keep_compute_id(windows_platform, async_run, tmpdir, controller)
|
||||
"compute_id": "local",
|
||||
"node_id": "0fd3dd4d-dc93-4a04-a9b9-7396a9e22e8b",
|
||||
"node_type": "iou",
|
||||
"name": "test",
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -35,11 +35,7 @@ def test_symbols(http_controller):
|
||||
def test_get(http_controller):
|
||||
response = http_controller.get('/symbols/' + urllib.parse.quote(':/symbols/firewall.svg') + '/raw')
|
||||
assert response.status == 200
|
||||
# Different carriage return
|
||||
if sys.platform.startswith("win"):
|
||||
assert response.headers['CONTENT-LENGTH'] == '9568'
|
||||
else:
|
||||
assert response.headers['CONTENT-LENGTH'] == '9381'
|
||||
assert response.headers['CONTENT-LENGTH'] == '9381'
|
||||
assert response.headers['CONTENT-TYPE'] == 'image/svg+xml'
|
||||
assert '</svg>' in response.html
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ def test_force_unix_path():
|
||||
assert force_unix_path("a\\b") == "a/b"
|
||||
assert force_unix_path("a\\b\\..\\c") == "a/c"
|
||||
assert force_unix_path("C:\Temp") == "C:/Temp"
|
||||
assert force_unix_path(force_unix_path("C:\Temp")) == "C:/Temp"
|
||||
assert force_unix_path("a//b") == "a/b"
|
||||
|
||||
|
||||
def test_macaddress_to_int():
|
||||
|
||||
+14
-11
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@@ -105,9 +106,10 @@ def test_list_images(tmpdir):
|
||||
path = tmpdir / "images2" / "test_invalid.image"
|
||||
path.write(b'NOTANELF', ensure=True)
|
||||
|
||||
path3 = tmpdir / "images1" / "IOU" / "test3.bin"
|
||||
path3.write(b'\x7fELF\x01\x02\x01', ensure=True)
|
||||
path3 = force_unix_path(str(path3))
|
||||
if sys.platform.startswith("linux"):
|
||||
path3 = tmpdir / "images1" / "IOU" / "test3.bin"
|
||||
path3.write(b'\x7fELF\x01\x02\x01', ensure=True)
|
||||
path3 = force_unix_path(str(path3))
|
||||
|
||||
path4 = tmpdir / "images1" / "QEMU" / "test4.qcow2"
|
||||
path4.write("1", ensure=True)
|
||||
@@ -137,14 +139,15 @@ def test_list_images(tmpdir):
|
||||
}
|
||||
]
|
||||
|
||||
assert list_images("iou") == [
|
||||
{
|
||||
'filename': 'test3.bin',
|
||||
'filesize': 7,
|
||||
'md5sum': 'b0d5aa897d937aced5a6b1046e8f7e2e',
|
||||
'path': 'test3.bin'
|
||||
}
|
||||
]
|
||||
if sys.platform.startswith("linux"):
|
||||
assert list_images("iou") == [
|
||||
{
|
||||
'filename': 'test3.bin',
|
||||
'filesize': 7,
|
||||
'md5sum': 'b0d5aa897d937aced5a6b1046e8f7e2e',
|
||||
'path': 'test3.bin'
|
||||
}
|
||||
]
|
||||
|
||||
assert list_images("qemu") == [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user