mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Add method to delete and update computes
This commit is contained in:
7 files changed
+143
-5
No files matched your search
@@ -201,3 +201,15 @@ def test_streamFile(project, async_run, compute):
|
||||
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
|
||||
async_run(compute.steam_file(project, "test/titi"))
|
||||
mock.assert_called_with("GET", "https://example.com:84/v2/compute/projects/{}/stream/test/titi".format(project.id), auth=None)
|
||||
|
||||
|
||||
def test_update(compute, controller, async_run):
|
||||
compute._controller._notification = MagicMock()
|
||||
compute.name = "Test"
|
||||
compute.host = "example.org"
|
||||
compute._connected = True
|
||||
async_run(compute.update(name="Test 2"))
|
||||
assert compute.name == "Test 2"
|
||||
assert compute.host == "example.org"
|
||||
controller.notification.emit.assert_called_with("compute.updated", compute.__json__())
|
||||
assert compute.connected is False
|
||||
@@ -87,6 +87,15 @@ def test_addCompute(controller, controller_config_path, async_run):
|
||||
assert len(controller.computes) == 2
|
||||
|
||||
|
||||
def test_deleteCompute(controller, controller_config_path, async_run):
|
||||
c = async_run(controller.add_compute("test1"))
|
||||
assert len(controller.computes) == 1
|
||||
controller._notification = MagicMock()
|
||||
async_run(controller.delete_compute("test1"))
|
||||
assert len(controller.computes) == 0
|
||||
controller._notification.emit.assert_called_with("compute.deleted", c.__json__())
|
||||
|
||||
|
||||
def test_addComputeConfigFile(controller, controller_config_path, async_run):
|
||||
async_run(controller.add_compute("test1"))
|
||||
assert len(controller.computes) == 1
|
||||
|
||||
@@ -54,6 +54,30 @@ def test_compute_get(http_controller, controller):
|
||||
assert response.json["protocol"] == "http"
|
||||
|
||||
|
||||
def test_compute_update(http_controller, controller):
|
||||
|
||||
params = {
|
||||
"compute_id": "my_compute/id",
|
||||
"protocol": "http",
|
||||
"host": "example.com",
|
||||
"port": 84,
|
||||
"user": "julien",
|
||||
"password": "secure"
|
||||
}
|
||||
response = http_controller.post("/computes", params)
|
||||
assert response.status == 201
|
||||
|
||||
response = http_controller.get("/computes/my_compute/id")
|
||||
assert response.status == 200
|
||||
assert response.json["protocol"] == "http"
|
||||
|
||||
params["protocol"] = "https"
|
||||
response = http_controller.put("/computes/my_compute/id", params, example=True)
|
||||
|
||||
assert response.status == 200
|
||||
assert response.json["protocol"] == "https"
|
||||
|
||||
|
||||
def test_compute_list(http_controller, controller):
|
||||
|
||||
params = {
|
||||
@@ -84,3 +108,26 @@ def test_compute_list(http_controller, controller):
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_compute_delete(http_controller, controller):
|
||||
|
||||
params = {
|
||||
"compute_id": "my_compute/id",
|
||||
"protocol": "http",
|
||||
"host": "example.com",
|
||||
"port": 84,
|
||||
"user": "julien",
|
||||
"password": "secure"
|
||||
}
|
||||
response = http_controller.post("/computes", params)
|
||||
assert response.status == 201
|
||||
|
||||
response = http_controller.get("/computes")
|
||||
assert len(response.json) == 1
|
||||
|
||||
response = http_controller.delete("/computes/my_compute/id")
|
||||
assert response.status == 204
|
||||
|
||||
response = http_controller.get("/computes")
|
||||
assert len(response.json) == 0
|
||||
Reference in new issue
Block a user