mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Update project API
This commit is contained in:
9 files changed
+74
-54
No files matched your search
@@ -62,6 +62,16 @@ def test_json(tmpdir):
|
||||
assert p.__json__() == {"name": "Test", "project_id": p.id, "path": p.path, "status": "opened", "filename": "Test.gns3"}
|
||||
|
||||
|
||||
def test_update(controller, async_run):
|
||||
project = Project(controller=controller, name="Hello")
|
||||
controller._notification = MagicMock()
|
||||
|
||||
assert project.name == "Hello"
|
||||
async_run(project.update(name="World"))
|
||||
assert project.name == "World"
|
||||
controller.notification.emit.assert_any_call("project.updated", project.__json__())
|
||||
|
||||
|
||||
def test_path(tmpdir):
|
||||
|
||||
directory = Config.instance().get_section_config("Server").get("projects_path")
|
||||
|
||||
@@ -97,7 +97,6 @@ def test_restore(project, controller, async_run):
|
||||
# project.closed notification should not be send when restoring snapshots
|
||||
assert "project.closed" not in [c[0][0] for c in controller.notification.emit.call_args_list]
|
||||
|
||||
|
||||
project = controller.get_project(project.id)
|
||||
assert not os.path.exists(test_file)
|
||||
assert len(project.nodes) == 1
|
||||
@@ -67,6 +67,18 @@ def test_create_project_with_uuid(http_controller):
|
||||
assert response.json["name"] == "test"
|
||||
|
||||
|
||||
def test_update_project(http_controller):
|
||||
query = {"name": "test", "project_id": "10010203-0405-0607-0809-0a0b0c0d0e0f"}
|
||||
response = http_controller.post("/projects", query)
|
||||
assert response.status == 201
|
||||
assert response.json["project_id"] == "10010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
assert response.json["name"] == "test"
|
||||
query = {"name": "test2"}
|
||||
response = http_controller.put("/projects/10010203-0405-0607-0809-0a0b0c0d0e0f", query, example=True)
|
||||
assert response.status == 200
|
||||
assert response.json["name"] == "test2"
|
||||
|
||||
|
||||
def test_list_projects(http_controller, tmpdir):
|
||||
http_controller.post("/projects", {"name": "test", "path": str(tmpdir), "project_id": "00010203-0405-0607-0809-0a0b0c0d0e0f"})
|
||||
response = http_controller.get("/projects", example=True)
|
||||
|
||||
Reference in new issue
Block a user