mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: report empty projects as not locked
GET /projects/{id}/locked returned True for a project with no drawings
or nodes: both loops ran zero times and the fallback return won. Locking
and unlocking such a project always succeeded while the state stayed
"locked", so it could never be unlocked.
Report a project with nothing to lock as not locked, and re-check the
state after unlock in the route tests.
This commit is contained in:
2 files changed
+30
No files matched your search
@@ -613,3 +613,29 @@ class TestControllerProjectRoutes:
|
||||
assert drawing.locked is False
|
||||
for node in project.nodes.values():
|
||||
assert node.locked is False
|
||||
|
||||
response = await client.get(app.url_path_for("locked_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() is False
|
||||
|
||||
async def test_lock_unlock_empty_project(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
||||
|
||||
# a project without drawings or nodes has nothing to lock and must
|
||||
# never report as locked, otherwise it could not be unlocked
|
||||
response = await client.get(app.url_path_for("locked_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() is False
|
||||
|
||||
response = await client.post(app.url_path_for("lock_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_204_NO_CONTENT
|
||||
|
||||
response = await client.get(app.url_path_for("locked_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() is False
|
||||
|
||||
response = await client.post(app.url_path_for("unlock_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_204_NO_CONTENT
|
||||
|
||||
response = await client.get(app.url_path_for("locked_project", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() is False
|
||||
Reference in new issue
Block a user