mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Merge branch '3.1' into images-nested-folders-support
This commit is contained in:
108 files changed
+919
-1844
No files matched your search
@@ -465,9 +465,7 @@ class TestNodeRoutes:
|
||||
|
||||
compute.http_query.assert_called_with(
|
||||
"GET",
|
||||
"/projects/{project_id}/files/project-files/vpcs/{node_id}/hello".format(
|
||||
project_id=project.id, node_id=node.id
|
||||
),
|
||||
f"/projects/{project.id}/files/project-files/vpcs/{node.id}/hello",
|
||||
timeout=None,
|
||||
stream=True,
|
||||
)
|
||||
@@ -491,16 +489,12 @@ class TestNodeRoutes:
|
||||
compute.http_query.assert_called_once()
|
||||
call_args = compute.http_query.call_args
|
||||
assert call_args[0][0] == "POST"
|
||||
assert call_args[0][1] == "/projects/{project_id}/files/project-files/vpcs/{node_id}/hello".format(
|
||||
project_id=project.id, node_id=node.id
|
||||
)
|
||||
assert call_args[0][1] == f"/projects/{project.id}/files/project-files/vpcs/{node.id}/hello"
|
||||
assert call_args[1]["timeout"] is None
|
||||
# data should be an async generator from request.stream()
|
||||
assert hasattr(call_args[1]["data"], "__aiter__")
|
||||
|
||||
response = await client.get(
|
||||
"/projects/{project_id}/nodes/{node_id}/files/../hello".format(project_id=project.id, node_id=node.id)
|
||||
)
|
||||
response = await client.get(f"/projects/{project.id}/nodes/{node.id}/files/../hello")
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
|
||||
@@ -117,6 +117,28 @@ class TestControllerProjectRoutes:
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json()["name"] == "test2"
|
||||
|
||||
async def test_update_project_ignores_path_and_project_id(
|
||||
self, app: FastAPI, client: AsyncClient, controller: Controller
|
||||
) -> None:
|
||||
|
||||
params = {"name": "test", "project_id": "10010203-0405-0607-0809-0a0b0c0d0e0f"}
|
||||
response = await client.post(app.url_path_for("create_project"), json=params)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
path = response.json()["path"]
|
||||
|
||||
params = {
|
||||
"name": "test2",
|
||||
"path": os.path.join(os.path.dirname(path), "other"),
|
||||
"project_id": "20010203-0405-0607-0809-0a0b0c0d0e0f",
|
||||
}
|
||||
response = await client.put(
|
||||
app.url_path_for("update_project", project_id="10010203-0405-0607-0809-0a0b0c0d0e0f"), json=params
|
||||
)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json()["name"] == "test2"
|
||||
assert response.json()["path"] == path
|
||||
assert response.json()["project_id"] == "10010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
async def test_update_project_with_variables(
|
||||
self, app: FastAPI, client: AsyncClient, controller: Controller
|
||||
) -> None:
|
||||
@@ -244,10 +266,9 @@ class TestControllerProjectRoutes:
|
||||
)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.headers["CONTENT-TYPE"] == "application/gns3project"
|
||||
assert response.headers[
|
||||
"CONTENT-DISPOSITION"
|
||||
] == "attachment; filename=\"{name}.gns3project\"; filename*=UTF-8''{name}.gns3project".format(
|
||||
name=project.name
|
||||
assert (
|
||||
response.headers["CONTENT-DISPOSITION"]
|
||||
== f"attachment; filename=\"{project.name}.gns3project\"; filename*=UTF-8''{project.name}.gns3project"
|
||||
)
|
||||
|
||||
with open(str(tmpdir / "project.zip"), "wb+") as f:
|
||||
@@ -283,10 +304,9 @@ class TestControllerProjectRoutes:
|
||||
)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.headers["CONTENT-TYPE"] == "application/gns3project"
|
||||
assert response.headers[
|
||||
"CONTENT-DISPOSITION"
|
||||
] == "attachment; filename=\"{name}.gns3project\"; filename*=UTF-8''{name}.gns3project".format(
|
||||
name=project.name
|
||||
assert (
|
||||
response.headers["CONTENT-DISPOSITION"]
|
||||
== f"attachment; filename=\"{project.name}.gns3project\"; filename*=UTF-8''{project.name}.gns3project"
|
||||
)
|
||||
with open(str(tmpdir / "project.zip"), "wb+") as f:
|
||||
f.write(response.content)
|
||||
@@ -343,10 +363,9 @@ class TestControllerProjectRoutes:
|
||||
|
||||
if response.status_code == status.HTTP_200_OK:
|
||||
assert response.headers["CONTENT-TYPE"] == "application/gns3project"
|
||||
assert response.headers[
|
||||
"CONTENT-DISPOSITION"
|
||||
] == "attachment; filename=\"{name}.gns3project\"; filename*=UTF-8''{name}.gns3project".format(
|
||||
name=project.name
|
||||
assert (
|
||||
response.headers["CONTENT-DISPOSITION"]
|
||||
== f"attachment; filename=\"{project.name}.gns3project\"; filename*=UTF-8''{project.name}.gns3project"
|
||||
)
|
||||
with open(str(tmpdir / "project.zip"), "wb+") as f:
|
||||
f.write(response.content)
|
||||
|
||||
@@ -42,9 +42,7 @@ class TestVersionRoutes:
|
||||
params = {"version": "0.4.2"}
|
||||
response = await client.post(app.url_path_for("check_version"), json=params)
|
||||
assert response.status_code == status.HTTP_409_CONFLICT
|
||||
assert response.json() == {
|
||||
"message": "Client version 0.4.2 is not the same as server version {}".format(__version__)
|
||||
}
|
||||
assert response.json() == {"message": f"Client version 0.4.2 is not the same as server version {__version__}"}
|
||||
|
||||
async def test_version_invalid_input_schema(self, app: FastAPI, client: AsyncClient) -> None:
|
||||
|
||||
|
||||
Reference in new issue
Block a user