mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Update script file
This commit is contained in:
1 parent
f99538ccef
commit
87a089457f
7 files changed
+90
-12
No files matched your search
+16
-3
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
import os
|
||||
from tests.api.base import server, loop, project
|
||||
from tests.utils import asyncio_patch
|
||||
from unittest.mock import patch
|
||||
@@ -38,13 +39,25 @@ def test_vpcs_create(server, project):
|
||||
assert response.json["script_file"] is None
|
||||
|
||||
|
||||
def test_vpcs_create_script_file(server, project):
|
||||
response = server.post("/vpcs", {"name": "PC TEST 1", "project_uuid": project.uuid, "script_file": "/tmp/test"})
|
||||
def test_vpcs_create_script_file(server, project, tmpdir):
|
||||
path = os.path.join(str(tmpdir), "test")
|
||||
with open(path, 'w+') as f:
|
||||
f.write("ip 192.168.1.2")
|
||||
response = server.post("/vpcs", {"name": "PC TEST 1", "project_uuid": project.uuid, "script_file": path})
|
||||
assert response.status == 200
|
||||
assert response.route == "/vpcs"
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_uuid"] == project.uuid
|
||||
assert response.json["script_file"] == "/tmp/test"
|
||||
assert response.json["script_file"] == path
|
||||
|
||||
|
||||
def test_vpcs_create_startup_script(server, project):
|
||||
response = server.post("/vpcs", {"name": "PC TEST 1", "project_uuid": project.uuid, "startup_script": "ip 192.168.1.2\necho TEST"})
|
||||
assert response.status == 200
|
||||
assert response.route == "/vpcs"
|
||||
assert response.json["name"] == "PC TEST 1"
|
||||
assert response.json["project_uuid"] == project.uuid
|
||||
assert response.json["startup_script"] == "ip 192.168.1.2\necho TEST"
|
||||
|
||||
|
||||
def test_vpcs_create_port(server, project):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
import pytest
|
||||
import asyncio
|
||||
import os
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
# TODO: Move loop to util
|
||||
@@ -111,3 +112,27 @@ def test_port_remove_nio_binding(vm):
|
||||
nio = vm.port_add_nio_binding(0, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
|
||||
vm.port_remove_nio_binding(0)
|
||||
assert vm._ethernet_adapter.ports[0] is None
|
||||
|
||||
|
||||
def test_update_startup_script(vm):
|
||||
content = "echo GNS3 VPCS\nip 192.168.1.2\n"
|
||||
vm.startup_script = content
|
||||
filepath = os.path.join(vm.working_dir, 'startup.vpcs')
|
||||
assert os.path.exists(filepath)
|
||||
with open(filepath) as f:
|
||||
assert f.read() == content
|
||||
|
||||
|
||||
def test_update_startup_script(vm):
|
||||
content = "echo GNS3 VPCS\nip 192.168.1.2\n"
|
||||
vm.startup_script = content
|
||||
filepath = os.path.join(vm.working_dir, 'startup.vpcs')
|
||||
assert os.path.exists(filepath)
|
||||
with open(filepath) as f:
|
||||
assert f.read() == content
|
||||
|
||||
|
||||
def test_get_startup_script(vm):
|
||||
content = "echo GNS3 VPCS\nip 192.168.1.2\n"
|
||||
vm.startup_script = content
|
||||
assert vm.startup_script == content
|
||||
Reference in new issue
Block a user