Merge remote-tracking branch 'origin/3.0' into gh-pages

This commit is contained in:
github-actions 2022-08-30 20:55:45 +00:00
commit 662ccddee2
56 changed files with 316 additions and 122 deletions

View File

@ -137,6 +137,13 @@
* Use parent directory as working directory for project duplication and snapshots. Fixes https://github.com/GNS3/gns3-gui/issues/2909 * Use parent directory as working directory for project duplication and snapshots. Fixes https://github.com/GNS3/gns3-gui/issues/2909
* Support for "usage" for "Cloud" nodes. Fixes https://github.com/GNS3/gns3-gui/issues/2887 Allow "usage" for all builtin nodes (not exposed in Ui). * Support for "usage" for "Cloud" nodes. Fixes https://github.com/GNS3/gns3-gui/issues/2887 Allow "usage" for all builtin nodes (not exposed in Ui).
## 2.2.34 28/08/2022
* Use original $PATH in init.sh for Docker containers. Ref #2069
* Support pytest-asyncio 0.19.0
* Upgrade dev dependencies and fix issues after upgrading to pytest-aiohttp v1.0.4
* Update compute.py
## 2.2.33.1 21/06/2022 ## 2.2.33.1 21/06/2022
* Add missing file for web-ui v2.2.33 * Add missing file for web-ui v2.2.33

View File

@ -1,8 +1,8 @@
-r requirements.txt -r requirements.txt
pytest==7.0.0 pytest==7.1.2
flake8==4.0.1 flake8==5.0.4
pytest-timeout==2.0.1 pytest-timeout==2.1.0
pytest-asyncio==0.16.0 pytest-asyncio==0.19.0
requests==2.26.0 requests==2.28.1
httpx==0.21.1 httpx==0.23.0

View File

@ -36,7 +36,6 @@ from fastapi.responses import StreamingResponse, FileResponse
from websockets.exceptions import ConnectionClosed, WebSocketException from websockets.exceptions import ConnectionClosed, WebSocketException
from typing import List, Optional from typing import List, Optional
from uuid import UUID from uuid import UUID
from pathlib import Path
from gns3server import schemas from gns3server import schemas
from gns3server.controller import Controller from gns3server.controller import Controller
@ -46,7 +45,6 @@ from gns3server.controller.import_project import import_project as import_contro
from gns3server.controller.export_project import export_project as export_controller_project from gns3server.controller.export_project import export_project as export_controller_project
from gns3server.utils.asyncio import aiozipstream from gns3server.utils.asyncio import aiozipstream
from gns3server.utils.path import is_safe_path from gns3server.utils.path import is_safe_path
from gns3server.config import Config
from gns3server.db.repositories.rbac import RbacRepository from gns3server.db.repositories.rbac import RbacRepository
from gns3server.db.repositories.templates import TemplatesRepository from gns3server.db.repositories.templates import TemplatesRepository
from gns3server.services.templates import TemplatesService from gns3server.services.templates import TemplatesService
@ -397,6 +395,24 @@ async def duplicate_project(
return new_project.asdict() return new_project.asdict()
@router.post("/{project_id}/lock", status_code=status.HTTP_204_NO_CONTENT)
async def lock_project(project: Project = Depends(dep_project)) -> None:
"""
Lock all drawings and nodes in a given project.
"""
project.lock()
@router.post("/{project_id}/unlock", status_code=status.HTTP_204_NO_CONTENT)
async def unlock_project(project: Project = Depends(dep_project)) -> None:
"""
Unlock all drawings and nodes in a given project.
"""
project.unlock()
@router.get("/{project_id}/files/{file_path:path}") @router.get("/{project_id}/files/{file_path:path}")
async def get_file(file_path: str, project: Project = Depends(dep_project)) -> FileResponse: async def get_file(file_path: str, project: Project = Depends(dep_project)) -> FileResponse:
""" """

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FAZ_VM64_KVM-v7.2.1-build1215-FORTINET.out.kvm.qcow2",
"version": "7.2.1",
"md5sum": "c13b6c7678a2fc12ab969fc681ad3af5",
"filesize": 340631552,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FAZ_VM64_KVM-v6-build2288-FORTINET.out.kvm.qcow2", "filename": "FAZ_VM64_KVM-v6-build2288-FORTINET.out.kvm.qcow2",
"version": "6.4.5", "version": "6.4.5",
@ -177,6 +184,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.2.1",
"images": {
"hda_disk_image": "FAZ_VM64_KVM-v7.2.1-build1215-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "6.4.5", "name": "6.4.5",
"images": { "images": {

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FGT_VM64_KVM-v7.2.1.F-build1254-FORTINET.out.kvm.qcow2",
"version": "7.2.1",
"md5sum": "e382a1ad5c7c16f49a1c0d3f45e3a3b2",
"filesize": 86704128,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FGT_VM64_KVM-v6-build1828-FORTINET.out.kvm.qcow2", "filename": "FGT_VM64_KVM-v6-build1828-FORTINET.out.kvm.qcow2",
"version": "6.4.5", "version": "6.4.5",
@ -254,6 +261,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.2.1",
"images": {
"hda_disk_image": "FGT_VM64_KVM-v7.2.1.F-build1254-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "6.4.5", "name": "6.4.5",
"images": { "images": {

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FML_VMKV-64-v721.M-build0364-FORTINET.out.kvm.qcow2",
"version": "7.2.1",
"md5sum": "b7bf13c2fb013693936b45d89dfab1ac",
"filesize": 123535360,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FML_VMKV-64-v60-build0257-FORTINET.out.kvm.qcow2", "filename": "FML_VMKV-64-v60-build0257-FORTINET.out.kvm.qcow2",
"version": "6.2.1", "version": "6.2.1",
@ -184,6 +191,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.2.1",
"images": {
"hda_disk_image": "FML_VMKV-64-v721.M-build0364-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "6.2.1", "name": "6.2.1",
"images": { "images": {

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FMG_VM64_KVM-v7.2.1-build1215-FORTINET.out.kvm.qcow2",
"version": "7.2.1",
"md5sum": "1a3eeff1204fa8f4243773f7521e12b5",
"filesize": 242814976,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FMG_VM64_KVM-v6-build2288-FORTINET.out.kvm.qcow2", "filename": "FMG_VM64_KVM-v6-build2288-FORTINET.out.kvm.qcow2",
"version": "6.4.5", "version": "6.4.5",
@ -177,6 +184,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.2.1",
"images": {
"hda_disk_image": "FMG_VM64_KVM-v7.2.1-build1215-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "6.4.5", "name": "6.4.5",
"images": { "images": {

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FPX_KVM-v700.M-build0102-FORTINET.out.kvm.qcow2",
"version": "7.0.6",
"md5sum": "ad0a4612580b5a2754cc4e0121a9cf22",
"filesize": 146800640,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FPX_KVM-v100-build0162-FORTINET.out.kvm.qcow2", "filename": "FPX_KVM-v100-build0162-FORTINET.out.kvm.qcow2",
"version": "1.1.2", "version": "1.1.2",
@ -51,6 +58,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.0.6",
"images": {
"hda_disk_image": "FPX_KVM-v700.M-build0102-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "1.1.2", "name": "1.1.2",
"images": { "images": {

View File

@ -28,6 +28,13 @@
"options": "-smp 2" "options": "-smp 2"
}, },
"images": [ "images": [
{
"filename": "FSA_KVM-v400-build0231-FORTINET.out.kvm.qcow2",
"version": "4.2.2",
"md5sum": "02b7f49e3c04861601a7af26452eed66",
"filesize": 156172304,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FSA_KVM-v300-build0124-FORTINET.out.kvm.qcow2", "filename": "FSA_KVM-v300-build0124-FORTINET.out.kvm.qcow2",
"version": "3.1.2", "version": "3.1.2",
@ -114,6 +121,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "4.2.2",
"images": {
"hda_disk_image": "FSA_KVM-v400-build0231-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "FSA-datadrive.qcow2"
}
},
{ {
"name": "3.1.2", "name": "3.1.2",
"images": { "images": {

View File

@ -27,6 +27,13 @@
"kvm": "allow" "kvm": "allow"
}, },
"images": [ "images": [
{
"filename": "FWB_KVM-v700-build0097-FORTINET.out.kvm.qcow2",
"version": "7.0.1",
"md5sum": "a197e9db03ffaf7feb520c8f77f940f7",
"filesize": 257622528,
"download_url": "https://support.fortinet.com/Download/FirmwareImages.aspx"
},
{ {
"filename": "FWB_KVM-v600-build0727-FORTINET.out.kvm.qcow2", "filename": "FWB_KVM-v600-build0727-FORTINET.out.kvm.qcow2",
"version": "6.2.1", "version": "6.2.1",
@ -121,6 +128,13 @@
} }
], ],
"versions": [ "versions": [
{
"name": "7.0.1",
"images": {
"hda_disk_image": "FWB_KVM-v700-build0097-FORTINET.out.kvm.qcow2",
"hdb_disk_image": "empty30G.qcow2"
}
},
{ {
"name": "6.2.1", "name": "6.2.1",
"images": { "images": {

View File

@ -20,7 +20,7 @@
# the start command of the container # the start command of the container
# #
OLD_PATH="$PATH" OLD_PATH="$PATH"
PATH=/gns3/bin:/tmp/gns3/bin:/sbin PATH=/gns3/bin:/tmp/gns3/bin:/sbin:$PATH
# bootstrap busybox commands # bootstrap busybox commands
if [ ! -d /tmp/gns3/bin ]; then if [ ! -d /tmp/gns3/bin ]; then

View File

@ -375,11 +375,6 @@ class Compute:
log.warning(f"Cannot connect to compute '{self._id}': {e}") log.warning(f"Cannot connect to compute '{self._id}': {e}")
# Try to reconnect after 5 seconds if server unavailable only if not during tests (otherwise we create a ressource usage bomb) # Try to reconnect after 5 seconds if server unavailable only if not during tests (otherwise we create a ressource usage bomb)
if not hasattr(sys, "_called_from_test") or not sys._called_from_test: if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
if self.id != "local" and self.id != "vm" and not self._controller.compute_has_open_project(self):
log.warning(
f"Not reconnecting to compute '{self._id}' because there is no project opened on it"
)
return
self._connection_failure += 1 self._connection_failure += 1
# After 5 failure we close the project using the compute to avoid sync issues # After 5 failure we close the project using the compute to avoid sync issues
if self._connection_failure == 10: if self._connection_failure == 10:

View File

@ -497,6 +497,7 @@ class Node:
"startup_config_content", "startup_config_content",
"private_config_content", "private_config_content",
"startup_script", "startup_script",
"custom_adapters"
]: ]:
if key in self._properties: if key in self._properties:
del self._properties[key] del self._properties[key]

View File

@ -1112,6 +1112,38 @@ class Project:
return True return True
return False return False
@open_required
def lock(self):
"""
Lock all drawings and nodes
"""
for drawing in self._drawings.values():
if not drawing.locked:
drawing.locked = True
self.emit_notification("drawing.updated", drawing.asdict())
for node in self.nodes.values():
if not node.locked:
node.locked = True
self.emit_notification("node.updated", node.asdict())
self.dump()
@open_required
def unlock(self):
"""
Unlock all drawings and nodes
"""
for drawing in self._drawings.values():
if drawing.locked:
drawing.locked = False
self.emit_notification("drawing.updated", drawing.asdict())
for node in self.nodes.values():
if node.locked:
node.locked = False
self.emit_notification("node.updated", node.asdict())
self.dump()
def dump(self): def dump(self):
""" """
Dump topology to disk Dump topology to disk

View File

@ -43,7 +43,7 @@ class CustomAdapter(BaseModel):
""" """
adapter_number: int adapter_number: int
port_name: Optional[str] = None port_name: str
adapter_type: Optional[str] = None adapter_type: Optional[str] = None
mac_address: Optional[str] = Field(None, regex="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$") mac_address: Optional[str] = Field(None, regex="^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$")

View File

@ -67,6 +67,7 @@ class DynamipsAdapters(str, Enum):
c1700_mb_wic1 = "C1700-MB-WIC1" c1700_mb_wic1 = "C1700-MB-WIC1"
gt96100_fe = "GT96100-FE" gt96100_fe = "GT96100-FE"
leopard_2fe = "Leopard-2FE" leopard_2fe = "Leopard-2FE"
_ = ""
class DynamipsWics(str, Enum): class DynamipsWics(str, Enum):

View File

@ -22,8 +22,8 @@
# or negative for a release candidate or beta (after the base version # or negative for a release candidate or beta (after the base version
# number has been incremented) # number has been incremented)
__version__ = "3.0.0a1" __version__ = "3.0.0dev4"
__version_info__ = (3, 0, 0, -99) __version_info__ = (3, 0, 0, 99)
if "dev" in __version__: if "dev" in __version__:
try: try:

View File

@ -1,20 +1,20 @@
uvicorn==0.18.2 uvicorn==0.18.3
fastapi==0.79.0 fastapi==0.81.0
python-multipart==0.0.5 python-multipart==0.0.5
websockets==10.3 websockets==10.3
aiohttp==3.8.1 aiohttp==3.8.1
async-timeout==4.0.2 async-timeout==4.0.2
aiofiles==0.8.0 aiofiles==0.8.0
Jinja2==3.1.2 Jinja2==3.1.2
sentry-sdk==1.7.1 sentry-sdk==1.9.5
psutil==5.9.1 psutil==5.9.1
distro==1.7.0 distro==1.7.0
py-cpuinfo==8.0.0 py-cpuinfo==8.0.0
sqlalchemy==1.4.39 sqlalchemy==1.4.40
aiosqlite===0.17.0 aiosqlite==0.17.0
passlib[bcrypt]==1.7.4 passlib[bcrypt]==1.7.4
python-jose==3.3.0 python-jose==3.3.0
email-validator==1.2.1 email-validator==1.2.1
watchfiles==0.15.0 watchfiles==0.16.1
zstandard==0.18.0 zstandard==0.18.0
setuptools==60.6.0 # don't upgrade because of https://github.com/pypa/setuptools/issues/3084 setuptools==60.6.0 # don't upgrade because of https://github.com/pypa/setuptools/issues/3084

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, on_gns3vm) -> dict: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, on_gns3vm) -> dict:
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._start_ubridge"): with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._start_ubridge"):

View File

@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import sys import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -55,7 +55,7 @@ def base_params() -> dict:
# Docker._instance = None # Docker._instance = None
@pytest.fixture @pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict:
with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]): with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]):

View File

@ -16,9 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import os import os
import stat import stat
import sys
import uuid import uuid
from fastapi import FastAPI, status from fastapi import FastAPI, status
@ -49,7 +49,7 @@ def base_params(tmpdir, fake_iou_bin) -> dict:
return {"application_id": 42, "name": "IOU-TEST-1", "path": "iou.bin"} return {"application_id": 42, "name": "IOU-TEST-1", "path": "iou.bin"}
@pytest.fixture @pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> dict:
response = await compute_client.post(app.url_path_for("compute:create_iou_node", project_id=compute_project.id), json=base_params) response = await compute_client.post(app.url_path_for("compute:create_iou_node", project_id=compute_project.id), json=base_params)

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -26,7 +27,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, ubridge_path: str, on_gns3vm) -> dict: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, ubridge_path: str, on_gns3vm) -> dict:
with asyncio_patch("gns3server.compute.builtin.nodes.nat.Nat._start_ubridge"): with asyncio_patch("gns3server.compute.builtin.nodes.nat.Nat._start_ubridge"):

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import os import os
import stat import stat
import shutil import shutil
@ -69,7 +70,7 @@ def base_params(tmpdir, fake_qemu_bin) -> dict:
return {"name": "QEMU-TEST-1", "qemu_path": fake_qemu_bin} return {"name": "QEMU-TEST-1", "qemu_path": fake_qemu_bin}
@pytest.fixture @pytest_asyncio.fixture
async def qemu_vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> None: async def qemu_vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, base_params: dict) -> None:
response = await compute_client.post( response = await compute_client.post(

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None:
vboxmanage_path = "/fake/VboxManage" vboxmanage_path = "/fake/VboxManage"

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, vmx_path: str) -> dict: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project, vmx_path: str) -> dict:
params = { params = {

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -27,7 +28,7 @@ from gns3server.compute.project import Project
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture @pytest_asyncio.fixture
async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None: async def vm(app: FastAPI, compute_client: AsyncClient, compute_project: Project) -> None:
params = {"name": "PC TEST 1"} params = {"name": "PC TEST 1"}

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -171,7 +172,7 @@ class TestGroupMembersRoutes:
assert len(members) == 0 assert len(members) == 0
@pytest.fixture @pytest_asyncio.fixture
async def test_role(db_session: AsyncSession) -> Role: async def test_role(db_session: AsyncSession) -> Role:
new_role = schemas.RoleCreate( new_role = schemas.RoleCreate(

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from typing import Tuple from typing import Tuple
from fastapi import FastAPI, status from fastapi import FastAPI, status
@ -34,7 +35,7 @@ from gns3server.controller.udp_link import UDPLink
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture @pytest_asyncio.fixture
async def nodes(compute: Compute, project: Project) -> Tuple[Node, Node]: async def nodes(compute: Compute, project: Project) -> Tuple[Node, Node]:
response = MagicMock() response = MagicMock()

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import uuid import uuid
from fastapi import FastAPI, status from fastapi import FastAPI, status
@ -31,7 +32,7 @@ pytestmark = pytest.mark.asyncio
class TestPermissionRoutes: class TestPermissionRoutes:
@pytest.fixture() @pytest_asyncio.fixture
async def project(self, app: FastAPI, client: AsyncClient, controller: Controller) -> Project: async def project(self, app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
project_uuid = str(uuid.uuid4()) project_uuid = str(uuid.uuid4())

View File

@ -19,26 +19,28 @@ import uuid
import os import os
import json import json
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
from unittest.mock import patch, MagicMock from unittest.mock import patch, MagicMock
from tests.utils import asyncio_patch from tests.utils import asyncio_patch, AsyncioMagicMock
import gns3server.utils.zipfile_zstd as zipfile_zstd import gns3server.utils.zipfile_zstd as zipfile_zstd
from gns3server.controller import Controller from gns3server.controller import Controller
from gns3server.controller.project import Project from gns3server.controller.project import Project
from gns3server.controller.compute import Compute
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture @pytest_asyncio.fixture
async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project: async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
u = str(uuid.uuid4()) project_id = str(uuid.uuid4())
params = {"name": "test", "project_id": u} params = {"name": "test", "project_id": project_id}
await client.post(app.url_path_for("create_project"), json=params) await client.post(app.url_path_for("create_project"), json=params)
return controller.get_project(u) return controller.get_project(project_id)
async def test_create_project_with_path(app: FastAPI, client: AsyncClient, controller: Controller, config) -> None: async def test_create_project_with_path(app: FastAPI, client: AsyncClient, controller: Controller, config) -> None:
@ -472,3 +474,47 @@ async def test_duplicate(app: FastAPI, client: AsyncClient, project: Project) ->
response = await client.post(app.url_path_for("duplicate_project", project_id=project.id), json={"name": "hello"}) response = await client.post(app.url_path_for("duplicate_project", project_id=project.id), json={"name": "hello"})
assert response.status_code == status.HTTP_201_CREATED assert response.status_code == status.HTTP_201_CREATED
assert response.json()["name"] == "hello" assert response.json()["name"] == "hello"
async def test_lock_unlock(app: FastAPI, client: AsyncClient, project: Project, compute: Compute) -> None:
# add a drawing and node to the project
params = {
"svg": '<svg height="210" width="500"><line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" /></svg>',
"x": 10,
"y": 20,
"z": 0
}
response = await client.post(app.url_path_for("create_drawing", project_id=project.id), json=params)
assert response.status_code == status.HTTP_201_CREATED
response = MagicMock()
response.json = {"console": 2048}
compute.post = AsyncioMagicMock(return_value=response)
response = await client.post(app.url_path_for("create_node", project_id=project.id), json={
"name": "test",
"node_type": "vpcs",
"compute_id": "example.com",
"properties": {
"startup_script": "echo test"
}
})
assert response.status_code == status.HTTP_201_CREATED
response = await client.post(app.url_path_for("lock_project", project_id=project.id))
assert response.status_code == status.HTTP_204_NO_CONTENT
for drawing in project.drawings.values():
assert drawing.locked is True
for node in project.nodes.values():
assert node.locked is True
response = await client.post(app.url_path_for("unlock_project", project_id=project.id))
assert response.status_code == status.HTTP_204_NO_CONTENT
for drawing in project.drawings.values():
assert drawing.locked is False
for node in project.nodes.values():
assert node.locked is False

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -105,7 +106,7 @@ class TestRolesRoutes:
assert response.status_code == status.HTTP_403_FORBIDDEN assert response.status_code == status.HTTP_403_FORBIDDEN
@pytest.fixture @pytest_asyncio.fixture
async def test_permission(db_session: AsyncSession) -> Permission: async def test_permission(db_session: AsyncSession) -> Permission:
new_permission = schemas.PermissionCreate( new_permission = schemas.PermissionCreate(

View File

@ -18,6 +18,7 @@
import os import os
import uuid import uuid
import pytest import pytest
import pytest_asyncio
from fastapi import FastAPI, status from fastapi import FastAPI, status
from httpx import AsyncClient from httpx import AsyncClient
@ -29,7 +30,7 @@ from gns3server.controller.snapshot import Snapshot
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@pytest.fixture @pytest_asyncio.fixture
async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project: async def project(app: FastAPI, client: AsyncClient, controller: Controller) -> Project:
u = str(uuid.uuid4()) u = str(uuid.uuid4())
@ -39,7 +40,7 @@ async def project(app: FastAPI, client: AsyncClient, controller: Controller) ->
return project return project
@pytest.fixture @pytest_asyncio.fixture
async def snapshot(project: Project): async def snapshot(project: Project):
snapshot = await project.snapshot("test") snapshot = await project.snapshot("test")

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from typing import Optional from typing import Optional
from fastapi import FastAPI, HTTPException, status from fastapi import FastAPI, HTTPException, status
@ -438,7 +439,8 @@ class TestSuperAdmin:
# assert response.status_code == status.HTTP_200_OK # assert response.status_code == status.HTTP_200_OK
# assert len(response.json()) == 1 # assert len(response.json()) == 1
@pytest.fixture
@pytest_asyncio.fixture
async def test_permission(db_session: AsyncSession) -> Permission: async def test_permission(db_session: AsyncSession) -> Permission:
new_permission = schemas.PermissionCreate( new_permission = schemas.PermissionCreate(

View File

@ -17,6 +17,7 @@
import uuid import uuid
import pytest import pytest
import pytest_asyncio
from unittest.mock import MagicMock, patch, call from unittest.mock import MagicMock, patch, call
from gns3server.compute.builtin.nodes.cloud import Cloud from gns3server.compute.builtin.nodes.cloud import Cloud
@ -30,8 +31,7 @@ def nio():
return NIOUDP(4242, "127.0.0.1", 4343) return NIOUDP(4242, "127.0.0.1", 4343)
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(): async def manager():
m = MagicMock() m = MagicMock()

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
@ -23,8 +24,7 @@ from gns3server.compute.docker import Docker, DOCKER_PREFERRED_API_VERSION, DOCK
from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def vm(): async def vm():
vm = Docker() vm = Docker()

View File

@ -18,8 +18,8 @@
import aiohttp import aiohttp
import asyncio import asyncio
import pytest import pytest
import pytest_asyncio
import uuid import uuid
import sys
import os import os
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
@ -33,8 +33,7 @@ from gns3server.utils.get_resource import get_resource
from unittest.mock import patch, MagicMock, call from unittest.mock import patch, MagicMock, call
@pytest.fixture() @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = Docker.instance() m = Docker.instance()
@ -42,8 +41,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager): async def vm(compute_project, manager):
vm = DockerVM("test", str(uuid.uuid4()), compute_project, manager, "ubuntu:latest", aux_type="none") vm = DockerVM("test", str(uuid.uuid4()), compute_project, manager, "ubuntu:latest", aux_type="none")

View File

@ -17,8 +17,8 @@
import pytest import pytest
import pytest_asyncio
import tempfile import tempfile
import sys
import uuid import uuid
import os import os
@ -28,8 +28,7 @@ from unittest.mock import patch
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = Dynamips.instance() m = Dynamips.instance()

View File

@ -18,7 +18,7 @@
import os import os
import uuid import uuid
import pytest import pytest
import asyncio import pytest_asyncio
from gns3server.compute.dynamips.nodes.router import Router from gns3server.compute.dynamips.nodes.router import Router
from gns3server.compute.dynamips.dynamips_error import DynamipsError from gns3server.compute.dynamips.dynamips_error import DynamipsError
@ -26,8 +26,7 @@ from gns3server.compute.dynamips import Dynamips
from gns3server.config import Config from gns3server.config import Config
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = Dynamips.instance() m = Dynamips.instance()

View File

@ -16,11 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import asyncio import asyncio
import os import os
import stat import stat
import socket import socket
import sys
import uuid import uuid
import shutil import shutil
@ -32,8 +32,7 @@ from gns3server.compute.iou.iou_error import IOUError
from gns3server.compute.iou import IOU from gns3server.compute.iou import IOU
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = IOU.instance() m = IOU.instance()
@ -41,8 +40,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager, config, tmpdir, fake_iou_bin, iourc_file): async def vm(compute_project, manager, config, tmpdir, fake_iou_bin, iourc_file):
vm = IOUVM("test", str(uuid.uuid4()), compute_project, manager, application_id=1) vm = IOUVM("test", str(uuid.uuid4()), compute_project, manager, application_id=1)

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import asyncio import asyncio
import os import os
import stat import stat
@ -32,8 +33,7 @@ from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddre
from gns3server.compute.notification_manager import NotificationManager from gns3server.compute.notification_manager import NotificationManager
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = Qemu.instance() m = Qemu.instance()
@ -63,8 +63,7 @@ def fake_qemu_binary(monkeypatch, tmpdir):
return bin_path return bin_path
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager, fake_qemu_binary, fake_qemu_img_binary): async def vm(compute_project, manager, fake_qemu_binary, fake_qemu_img_binary):
manager.port_manager.console_host = "127.0.0.1" manager.port_manager.console_host = "127.0.0.1"

View File

@ -18,7 +18,7 @@
from collections import OrderedDict from collections import OrderedDict
import pytest import pytest
import asyncio import pytest_asyncio
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
@ -29,8 +29,7 @@ from gns3server.compute.vpcs import VPCS
from gns3server.compute.nios.nio_udp import NIOUDP from gns3server.compute.nios.nio_udp import NIOUDP
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VPCS.instance() m = VPCS.instance()

View File

@ -18,6 +18,7 @@
import uuid import uuid
import os import os
import pytest import pytest
import pytest_asyncio
from unittest.mock import patch, MagicMock from unittest.mock import patch, MagicMock
from tests.utils import asyncio_patch from tests.utils import asyncio_patch
@ -28,8 +29,7 @@ from gns3server.compute.error import NodeError, ImageMissingError
from gns3server.utils import force_unix_path from gns3server.utils import force_unix_path
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vpcs(port_manager): async def vpcs(port_manager):
VPCS._instance = None VPCS._instance = None
@ -38,8 +38,7 @@ async def vpcs(port_manager):
return vpcs return vpcs
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def qemu(port_manager): async def qemu(port_manager):
Qemu._instance = None Qemu._instance = None

View File

@ -19,6 +19,7 @@
import os import os
import uuid import uuid
import pytest import pytest
import pytest_asyncio
from uuid import uuid4 from uuid import uuid4
from unittest.mock import patch from unittest.mock import patch
@ -29,8 +30,7 @@ from gns3server.compute.compute_error import ComputeError, ComputeForbiddenError
from gns3server.compute.vpcs import VPCS, VPCSVM from gns3server.compute.vpcs import VPCS, VPCSVM
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VPCS.instance() m = VPCS.instance()
@ -38,8 +38,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def node(compute_project, manager): async def node(compute_project, manager):
node = manager.create_node("test", compute_project.id, "00010203-0405-0607-0809-0a0b0c0d0e0f") node = manager.create_node("test", compute_project.id, "00010203-0405-0607-0809-0a0b0c0d0e0f")

View File

@ -17,6 +17,7 @@
import pytest import pytest
import pytest_asyncio
import tempfile import tempfile
import os import os
import stat import stat
@ -28,7 +29,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from tests.utils import asyncio_patch from tests.utils import asyncio_patch
@pytest.fixture @pytest_asyncio.fixture
async def manager(port_manager): async def manager(port_manager):
m = VirtualBox.instance() m = VirtualBox.instance()

View File

@ -17,6 +17,7 @@
import os import os
import pytest import pytest
import pytest_asyncio
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM
@ -24,8 +25,7 @@ from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from gns3server.compute.virtualbox import VirtualBox from gns3server.compute.virtualbox import VirtualBox
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VirtualBox.instance() m = VirtualBox.instance()
@ -33,8 +33,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager): async def vm(compute_project, manager):
return VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, "test", False) return VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager, "test", False)

View File

@ -16,13 +16,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest_asyncio
from gns3server.compute.vmware import VMware from gns3server.compute.vmware import VMware
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VMware.instance() m = VMware.instance()

View File

@ -16,13 +16,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from gns3server.compute.vmware.vmware_vm import VMwareVM from gns3server.compute.vmware.vmware_vm import VMwareVM
from gns3server.compute.vmware import VMware from gns3server.compute.vmware import VMware
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VMware.instance() m = VMware.instance()
@ -30,8 +30,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager, tmpdir): async def vm(compute_project, manager, tmpdir):
fake_vmx = str(tmpdir / "test.vmx") fake_vmx = str(tmpdir / "test.vmx")

View File

@ -16,9 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
import asyncio import asyncio
import os import os
import sys
from tests.utils import asyncio_patch, AsyncioMagicMock from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.utils import parse_version from gns3server.utils import parse_version
@ -30,8 +30,7 @@ from gns3server.compute.vpcs import VPCS
from gns3server.compute.notification_manager import NotificationManager from gns3server.compute.notification_manager import NotificationManager
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def manager(port_manager): async def manager(port_manager):
m = VPCS.instance() m = VPCS.instance()
@ -39,8 +38,7 @@ async def manager(port_manager):
return m return m
@pytest.fixture(scope="function") @pytest_asyncio.fixture(scope="function")
@pytest.mark.asyncio
async def vm(compute_project, manager, tmpdir, ubridge_path): async def vm(compute_project, manager, tmpdir, ubridge_path):
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager) vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager)

View File

@ -1,5 +1,6 @@
import pytest import pytest
import asyncio import asyncio
import pytest_asyncio
import tempfile import tempfile
import shutil import shutil
import sys import sys
@ -43,14 +44,14 @@ def event_loop(request):
loop.close() loop.close()
@pytest.fixture(scope="class") @pytest_asyncio.fixture(scope="class")
async def app() -> FastAPI: async def app() -> FastAPI:
from gns3server.api.server import app as gns3app from gns3server.api.server import app as gns3app
yield gns3app yield gns3app
@pytest.fixture(scope="class") @pytest_asyncio.fixture(scope="class")
async def db_engine(): async def db_engine():
db_url = os.getenv("GNS3_TEST_DATABASE_URI", "sqlite+aiosqlite:///:memory:") # "sqlite:///./sql_test_app.db" db_url = os.getenv("GNS3_TEST_DATABASE_URI", "sqlite+aiosqlite:///:memory:") # "sqlite:///./sql_test_app.db"
@ -59,7 +60,7 @@ async def db_engine():
#await engine.sync_engine.dispose() #await engine.sync_engine.dispose()
@pytest.fixture(scope="class") @pytest_asyncio.fixture(scope="class")
async def db_session(db_engine): async def db_session(db_engine):
# recreate database tables for each class # recreate database tables for each class
@ -80,7 +81,7 @@ async def db_session(db_engine):
await session.close() await session.close()
@pytest.fixture @pytest_asyncio.fixture
async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncClient: async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncClient:
async def _get_test_db(): async def _get_test_db():
@ -99,7 +100,7 @@ async def base_client(app: FastAPI, db_session: AsyncSession) -> AsyncClient:
yield async_client yield async_client
@pytest.fixture @pytest_asyncio.fixture
async def test_user(db_session: AsyncSession) -> User: async def test_user(db_session: AsyncSession) -> User:
new_user = schemas.UserCreate( new_user = schemas.UserCreate(
@ -119,7 +120,7 @@ async def test_user(db_session: AsyncSession) -> User:
return user return user
@pytest.fixture @pytest_asyncio.fixture
async def test_compute(db_session: AsyncSession) -> Compute: async def test_compute(db_session: AsyncSession) -> Compute:
new_compute = schemas.ComputeCreate( new_compute = schemas.ComputeCreate(
@ -154,7 +155,7 @@ def authorized_client(base_client: AsyncClient, test_user: User) -> AsyncClient:
return base_client return base_client
@pytest.fixture @pytest_asyncio.fixture
async def client(base_client: AsyncClient) -> AsyncClient: async def client(base_client: AsyncClient) -> AsyncClient:
# The super admin is automatically created when the users table is created # The super admin is automatically created when the users table is created
@ -167,7 +168,7 @@ async def client(base_client: AsyncClient) -> AsyncClient:
return base_client return base_client
@pytest.fixture @pytest_asyncio.fixture
async def compute_client(base_client: AsyncClient) -> AsyncClient: async def compute_client(base_client: AsyncClient) -> AsyncClient:
# default compute username is 'admin' # default compute username is 'admin'
@ -206,8 +207,7 @@ def compute(controller):
return compute return compute
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def project(tmpdir, controller): async def project(tmpdir, controller):
return await controller.add_project(name="Test") return await controller.add_project(name="Test")

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from tests.utils import asyncio_patch from tests.utils import asyncio_patch
from gns3server.utils.asyncio import wait_run_in_executor from gns3server.utils.asyncio import wait_run_in_executor
@ -23,8 +24,7 @@ from gns3server.utils.asyncio import wait_run_in_executor
from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def gns3vm(controller): async def gns3vm(controller):
vm = VirtualBoxGNS3VM(controller) vm = VirtualBoxGNS3VM(controller)

View File

@ -16,12 +16,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from gns3server.controller.gns3vm.vmware_gns3_vm import VMwareGNS3VM from gns3server.controller.gns3vm.vmware_gns3_vm import VMwareGNS3VM
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def gns3vm(controller): async def gns3vm(controller):
vm = VMwareGNS3VM(controller) vm = VMwareGNS3VM(controller)

View File

@ -19,6 +19,7 @@
import os import os
import json import json
import pytest import pytest
import pytest_asyncio
import zipfile import zipfile
from pathlib import Path from pathlib import Path
@ -32,8 +33,7 @@ from gns3server.utils.asyncio import aiozipstream
from gns3server.controller.controller_error import ControllerError from gns3server.controller.controller_error import ControllerError
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def project(controller): async def project(controller):
p = Project(controller=controller, name="test") p = Project(controller=controller, name="test")
@ -41,8 +41,7 @@ async def project(controller):
return p return p
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def node(controller, project): async def node(controller, project):
compute = MagicMock() compute = MagicMock()

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from unittest.mock import MagicMock from unittest.mock import MagicMock
from gns3server.controller.link import Link from gns3server.controller.link import Link
@ -26,8 +27,7 @@ from gns3server.controller.controller_error import ControllerError
from tests.utils import AsyncioBytesIO, AsyncioMagicMock from tests.utils import AsyncioBytesIO, AsyncioMagicMock
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def link(project, compute): async def link(project, compute):
node1 = Node(project, compute, "node1", node_type="qemu") node1 = Node(project, compute, "node1", node_type="qemu")

View File

@ -30,6 +30,7 @@ def compute():
s.id = "http://test.com:42" s.id = "http://test.com:42"
return s return s
@pytest.fixture @pytest.fixture
def node(compute, project): def node(compute, project):
node = Node(project, compute, "demo", node = Node(project, compute, "demo",

View File

@ -16,13 +16,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
import pytest_asyncio
from unittest.mock import MagicMock from unittest.mock import MagicMock
from tests.utils import AsyncioMagicMock from tests.utils import AsyncioMagicMock
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def node(project): async def node(project):
compute = MagicMock() compute = MagicMock()

View File

@ -17,9 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sys
import uuid import uuid
import pytest import pytest
import pytest_asyncio
from unittest.mock import MagicMock from unittest.mock import MagicMock
from tests.utils import AsyncioMagicMock, asyncio_patch from tests.utils import AsyncioMagicMock, asyncio_patch
from unittest.mock import patch from unittest.mock import patch
@ -32,8 +32,7 @@ from gns3server.controller.controller_error import ControllerError, ControllerNo
from gns3server.config import Config from gns3server.config import Config
@pytest.fixture @pytest_asyncio.fixture
@pytest.mark.asyncio
async def node(controller, project): async def node(controller, project):
compute = MagicMock() compute = MagicMock()