mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-18 20:37:57 +00:00
API method for getting a node
This commit is contained in:
parent
9fbe23e09b
commit
77eae35778
@ -53,6 +53,21 @@ class NodeHandler:
|
||||
response.set_status(201)
|
||||
response.json(node)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/nodes/{node_id}",
|
||||
status_codes={
|
||||
200: "Node found",
|
||||
400: "Invalid request",
|
||||
404: "Node doesn't exist"
|
||||
},
|
||||
description="Update a node instance",
|
||||
output=NODE_OBJECT_SCHEMA)
|
||||
def get_node(request, response):
|
||||
project = Controller.instance().get_project(request.match_info["project_id"])
|
||||
node = project.get_node(request.match_info["node_id"])
|
||||
response.set_status(200)
|
||||
response.json(node)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/nodes",
|
||||
parameters={
|
||||
|
@ -91,6 +91,24 @@ def test_list_node(http_controller, tmpdir, project, compute):
|
||||
assert response.json[0]["name"] == "test"
|
||||
|
||||
|
||||
def test_get_node(http_controller, tmpdir, project, compute):
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
response = http_controller.post("/projects/{}/nodes".format(project.id), {
|
||||
"name": "test",
|
||||
"node_type": "vpcs",
|
||||
"compute_id": "example.com",
|
||||
"properties": {
|
||||
"startup_script": "echo test"
|
||||
}
|
||||
})
|
||||
response = http_controller.get("/projects/{}/nodes/{}".format(project.id, response.json["node_id"]), example=True)
|
||||
assert response.status == 200
|
||||
assert response.json["name"] == "test"
|
||||
|
||||
|
||||
def test_update_node(http_controller, tmpdir, project, compute, node):
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
|
Loading…
Reference in New Issue
Block a user