mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 14:31:13 +02:00
refactor: ruff autofixes
This commit is contained in:
455 files changed
+12322
-14762
No files matched your search
@@ -31,48 +31,52 @@ pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
class TestSnapshotRoutes:
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def project(self, app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
|
||||
|
||||
|
||||
u = str(uuid.uuid4())
|
||||
params = {"name": "test", "project_id": u}
|
||||
await client.post(app.url_path_for("create_project"), json=params)
|
||||
controller_project = controller.get_project(u)
|
||||
return controller_project
|
||||
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def snapshot(self, project: Project):
|
||||
|
||||
|
||||
controller_snapshot = await project.snapshot("test")
|
||||
return controller_snapshot
|
||||
|
||||
|
||||
async def test_list_snapshots(self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot) -> None:
|
||||
|
||||
|
||||
async def test_list_snapshots(
|
||||
self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot
|
||||
) -> None:
|
||||
|
||||
assert snapshot.name == "test"
|
||||
response = await client.get(app.url_path_for("get_snapshots", project_id=project.id))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert len(response.json()) == 1
|
||||
|
||||
|
||||
async def test_delete_snapshot(self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot) -> None:
|
||||
|
||||
response = await client.delete(app.url_path_for("delete_snapshot", project_id=project.id, snapshot_id=snapshot.id))
|
||||
|
||||
async def test_delete_snapshot(
|
||||
self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot
|
||||
) -> None:
|
||||
|
||||
response = await client.delete(
|
||||
app.url_path_for("delete_snapshot", project_id=project.id, snapshot_id=snapshot.id)
|
||||
)
|
||||
assert response.status_code == status.HTTP_204_NO_CONTENT
|
||||
assert not os.path.exists(snapshot.path)
|
||||
|
||||
|
||||
async def test_restore_snapshot(self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot) -> None:
|
||||
|
||||
response = await client.post(app.url_path_for("restore_snapshot", project_id=project.id, snapshot_id=snapshot.id))
|
||||
|
||||
async def test_restore_snapshot(
|
||||
self, app: FastAPI, client: AsyncClient, project: Project, snapshot: Snapshot
|
||||
) -> None:
|
||||
|
||||
response = await client.post(
|
||||
app.url_path_for("restore_snapshot", project_id=project.id, snapshot_id=snapshot.id)
|
||||
)
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert response.json()["name"] == project.name
|
||||
|
||||
|
||||
|
||||
async def test_create_snapshot(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
||||
|
||||
|
||||
response = await client.post(app.url_path_for("create_snapshot", project_id=project.id), json={"name": "snap1"})
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert len(os.listdir(os.path.join(project.path, "snapshots"))) == 2
|
||||
Reference in new issue
Block a user