From 547adf0dc6ab4bc4a0a6c3a728bde6a7ac9fe20b Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 23 Jan 2015 16:18:40 +0100 Subject: [PATCH] Get project --- gns3server/handlers/project_handler.py | 18 ++++++++++++++++++ tests/api/test_project.py | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/gns3server/handlers/project_handler.py b/gns3server/handlers/project_handler.py index a7cbff0f..cc393c6c 100644 --- a/gns3server/handlers/project_handler.py +++ b/gns3server/handlers/project_handler.py @@ -39,6 +39,24 @@ class ProjectHandler: ) response.json(p) + @classmethod + @Route.get( + r"/project/{uuid}", + description="Get project informations", + parameters={ + "uuid": "Project instance UUID", + }, + status_codes={ + 200: "OK", + 404: "Project instance doesn't exist" + }, + output=PROJECT_OBJECT_SCHEMA) + def show(request, response): + + pm = ProjectManager.instance() + project = pm.get_project(request.match_info["uuid"]) + response.json(project) + @classmethod @Route.put( r"/project/{uuid}", diff --git a/tests/api/test_project.py b/tests/api/test_project.py index 4c2c6d22..eaa70982 100644 --- a/tests/api/test_project.py +++ b/tests/api/test_project.py @@ -60,6 +60,19 @@ def test_create_project_with_uuid(server): assert response.json["location"] == "/tmp" +def test_show_project(server): + query = {"uuid": "00010203-0405-0607-0809-0a0b0c0d0e0f", "location": "/tmp", "temporary": False} + response = server.post("/project", query) + assert response.status == 200 + response = server.get("/project/00010203-0405-0607-0809-0a0b0c0d0e0f") + assert response.json == query + + +def test_show_project_invalid_uuid(server): + response = server.get("/project/00010203-0405-0607-0809-0a0b0c0d0e42") + assert response.status == 404 + + def test_update_temporary_project(server): query = {"temporary": True} response = server.post("/project", query)