mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch '2.1' into 2.2
# Conflicts: # gns3server/version.py # requirements.txt
This commit is contained in:
commit
d1ccf3bc84
24 files changed
+549
-46
No files matched your search
@@ -32,7 +32,7 @@ pytestmark = pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supp
|
||||
@pytest.fixture
|
||||
def base_params():
|
||||
"""Return standard parameters"""
|
||||
return {"name": "PC TEST 1", "image": "nginx", "start_command": "nginx-daemon", "adapters": 2, "environment": "YES=1\nNO=0", "console_type": "telnet", "console_resolution": "1280x1024"}
|
||||
return {"name": "PC TEST 1", "image": "nginx", "start_command": "nginx-daemon", "adapters": 2, "environment": "YES=1\nNO=0", "console_type": "telnet", "console_resolution": "1280x1024", "extra_hosts": "test:127.0.0.1"}
|
||||
|
||||
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
@@ -69,7 +69,7 @@ def test_docker_create(http_compute, project, base_params):
|
||||
assert response.json["adapters"] == 2
|
||||
assert response.json["environment"] == "YES=1\nNO=0"
|
||||
assert response.json["console_resolution"] == "1280x1024"
|
||||
|
||||
assert response.json["extra_hosts"] == "test:127.0.0.1"
|
||||
|
||||
def test_docker_start(http_compute, vm):
|
||||
with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.start", return_value=True) as mock:
|
||||
@@ -150,7 +150,8 @@ def test_docker_update(http_compute, vm, tmpdir, free_console_port):
|
||||
response = http_compute.put("/projects/{project_id}/docker/nodes/{node_id}".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"name": "test",
|
||||
"console": free_console_port,
|
||||
"start_command": "yes",
|
||||
"environment": "GNS3=1\nGNS4=0"},
|
||||
"environment": "GNS3=1\nGNS4=0",
|
||||
"extra_hosts": "test:127.0.0.1"},
|
||||
example=True)
|
||||
assert mock.called
|
||||
assert response.status == 200
|
||||
@@ -158,6 +159,7 @@ def test_docker_update(http_compute, vm, tmpdir, free_console_port):
|
||||
assert response.json["console"] == free_console_port
|
||||
assert response.json["start_command"] == "yes"
|
||||
assert response.json["environment"] == "GNS3=1\nGNS4=0"
|
||||
assert response.json["extra_hosts"] == "test:127.0.0.1"
|
||||
|
||||
|
||||
def test_docker_start_capture(http_compute, vm, tmpdir, project):
|
||||
|
||||
@@ -21,9 +21,6 @@ This test suite check /project endpoint
|
||||
|
||||
import uuid
|
||||
import os
|
||||
import asyncio
|
||||
import aiohttp
|
||||
import zipfile
|
||||
|
||||
from unittest.mock import patch
|
||||
from tests.utils import asyncio_patch
|
||||
@@ -60,9 +57,10 @@ def test_show_project(http_compute):
|
||||
response = http_compute.post("/projects", query)
|
||||
assert response.status == 201
|
||||
response = http_compute.get("/projects/40010203-0405-0607-0809-0a0b0c0d0e02", example=True)
|
||||
assert len(response.json.keys()) == 2
|
||||
assert len(response.json.keys()) == 3
|
||||
assert response.json["project_id"] == "40010203-0405-0607-0809-0a0b0c0d0e02"
|
||||
assert response.json["name"] == "test"
|
||||
assert response.json["variables"] is None
|
||||
|
||||
|
||||
def test_show_project_invalid_uuid(http_compute):
|
||||
@@ -93,6 +91,23 @@ def test_delete_project(http_compute, project):
|
||||
assert mock.called
|
||||
|
||||
|
||||
def test_update_project(http_compute):
|
||||
query = {"name": "test", "project_id": "51010203-0405-0607-0809-0a0b0c0d0e0f"}
|
||||
response = http_compute.post("/projects", query)
|
||||
assert response.status == 201
|
||||
|
||||
query = {
|
||||
"variables": [{"name": "TEST1", "value": "VAL1"}]
|
||||
}
|
||||
response = http_compute.put(
|
||||
"/projects/{project_id}".format(project_id="51010203-0405-0607-0809-0a0b0c0d0e0f"),
|
||||
query,
|
||||
example=True
|
||||
)
|
||||
assert response.status == 200
|
||||
assert response.json["variables"] == [{"name": "TEST1", "value": "VAL1"}]
|
||||
|
||||
|
||||
def test_delete_project_invalid_uuid(http_compute):
|
||||
response = http_compute.delete("/projects/{project_id}".format(project_id=uuid.uuid4()))
|
||||
assert response.status == 404
|
||||
|
||||
Reference in new issue
Block a user