mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge remote-tracking branch 'origin/2.0' into 2.0
Conflicts: gns3server/controller/project.py tests/compute/test_project.py tests/controller/test_project.py
This commit is contained in:
commit
483431438a
17 files changed
+208
-53
No files matched your search
@@ -86,6 +86,7 @@ def test_compute_httpQueryNotConnected(compute, async_run):
|
||||
mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
|
||||
mock.assert_any_call("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
|
||||
assert compute._connected
|
||||
assert compute.version == __version__
|
||||
|
||||
|
||||
def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run):
|
||||
|
||||
@@ -108,6 +108,15 @@ def test_getCompute(controller, async_run):
|
||||
assert controller.getCompute("dsdssd")
|
||||
|
||||
|
||||
def test_addComputeLocal(controller, controller_config_path, async_run):
|
||||
"""
|
||||
The local node is the controller itself you can not change the informations
|
||||
"""
|
||||
Config.instance().set("Server", "local", True)
|
||||
async_run(controller.addCompute("local", host="example.org"))
|
||||
assert controller.getCompute("local").host == "localhost"
|
||||
|
||||
|
||||
def test_addProject(controller, async_run):
|
||||
uuid1 = str(uuid.uuid4())
|
||||
uuid2 = str(uuid.uuid4())
|
||||
@@ -138,7 +147,6 @@ def test_addProject_with_compute(controller, async_run):
|
||||
controller._computes = {"test1": compute}
|
||||
|
||||
project1 = async_run(controller.addProject(project_id=uuid1))
|
||||
compute.post.assert_called_with("/projects", project1)
|
||||
|
||||
|
||||
def test_getProject(controller, async_run):
|
||||
|
||||
@@ -43,9 +43,9 @@ def test_json(tmpdir):
|
||||
|
||||
def test_path(tmpdir):
|
||||
|
||||
directory = Config.instance().get_section_config("Server").get("project_directory")
|
||||
directory = Config.instance().get_section_config("Server").get("projects_path")
|
||||
|
||||
with patch("gns3server.compute.project.Project._get_default_project_directory", return_value=directory):
|
||||
with patch("gns3server.utils.path.get_default_project_directory", return_value=directory):
|
||||
p = Project(project_id=str(uuid4()))
|
||||
assert p.path == os.path.join(directory, p.id)
|
||||
assert os.path.exists(os.path.join(directory, p.id))
|
||||
@@ -68,6 +68,12 @@ def test_captures_directory(tmpdir):
|
||||
assert p.captures_directory == str(tmpdir / "project-files" / "captures")
|
||||
assert os.path.exists(p.captures_directory)
|
||||
|
||||
def test_add_compute(async_run):
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
async_run(project.addCompute(compute))
|
||||
assert compute in project._computes
|
||||
|
||||
|
||||
def test_addVM(async_run):
|
||||
compute = MagicMock()
|
||||
@@ -79,11 +85,12 @@ def test_addVM(async_run):
|
||||
|
||||
vm = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
|
||||
compute.post.assert_called_with('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': vm.id,
|
||||
'console_type': 'telnet',
|
||||
'startup_config': 'test.cfg',
|
||||
'name': 'test'})
|
||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||
data={'node_id': node.id,
|
||||
'console_type': 'telnet',
|
||||
'startup_config': 'test.cfg',
|
||||
'name': 'test'})
|
||||
assert compute in project._project_created_on_compute
|
||||
|
||||
|
||||
def test_getVM(async_run):
|
||||
|
||||
Reference in new issue
Block a user