mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Pydantic v2 migration
This commit is contained in:
1 parent
11f51b3809
commit
9c456532d0
46 files changed
+221
-277
No files matched your search
@@ -54,7 +54,7 @@ class TestComputeRoutes:
|
||||
params = {
|
||||
"compute_id": compute_id,
|
||||
"protocol": "http",
|
||||
"host": "localhost",
|
||||
"host": "127.0.0.1",
|
||||
"port": 84,
|
||||
"user": "julien",
|
||||
"password": "secure"}
|
||||
|
||||
@@ -90,7 +90,7 @@ async def test_create_project_with_supplier(app: FastAPI, client: AsyncClient, c
|
||||
|
||||
supplier = {
|
||||
'logo': 'logo.png',
|
||||
'url': 'http://example.com'
|
||||
'url': 'http://example.com/'
|
||||
}
|
||||
params = {"name": "test", "project_id": "30010203-0405-0607-0809-0a0b0c0d0e0f", "supplier": supplier}
|
||||
response = await client.post(app.url_path_for("create_project"), json=params)
|
||||
|
||||
@@ -70,8 +70,8 @@ class TestUserRoutes:
|
||||
assert user_in_db.username == params["username"]
|
||||
|
||||
# check that the user returned in the response is equal to the user in the database
|
||||
created_user = User(**response.json()).json()
|
||||
assert created_user == User.from_orm(user_in_db).json()
|
||||
created_user = User(**response.json()).model_dump_json()
|
||||
assert created_user == User.model_validate(user_in_db).model_dump_json()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"attr, value, status_code",
|
||||
|
||||
@@ -364,6 +364,7 @@ async def test_install_base_configs(controller, config, tmpdir):
|
||||
assert f.read() == 'test'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"builtin_disk",
|
||||
[
|
||||
@@ -383,7 +384,7 @@ async def test_install_base_configs(controller, config, tmpdir):
|
||||
)
|
||||
async def test_install_builtin_disks(controller, config, tmpdir, builtin_disk):
|
||||
|
||||
config.set_section_config("Server", {"images_path": str(tmpdir)})
|
||||
config.settings.Server.images_path = str(tmpdir)
|
||||
controller._install_builtin_disks()
|
||||
# we only install Qemu empty disks at this time
|
||||
assert os.path.exists(str(tmpdir / "QEMU" / builtin_disk))
|
||||
|
||||
@@ -74,7 +74,7 @@ def test_server_settings_to_list(tmpdir, setting: str, value: str, result: str):
|
||||
}
|
||||
})
|
||||
|
||||
assert config.settings.dict(exclude_unset=True)["Server"][setting] == result
|
||||
assert config.settings.model_dump(exclude_unset=True)["Server"][setting] == result
|
||||
|
||||
|
||||
def test_reload(tmpdir):
|
||||
@@ -109,7 +109,7 @@ def test_server_password_hidden():
|
||||
"settings, exception_expected",
|
||||
(
|
||||
({"protocol": "https1"}, True),
|
||||
({"console_start_port_range": 15000}, False),
|
||||
({"console_start_port_range": 15000, "console_end_port_range": 20000}, False),
|
||||
({"console_start_port_range": 0}, True),
|
||||
({"console_start_port_range": 68000}, True),
|
||||
({"console_end_port_range": 15000}, False),
|
||||
|
||||
@@ -86,14 +86,8 @@ def test_parse_arguments(capsys, config, tmpdir):
|
||||
server_config.enable_ssl = True
|
||||
assert server._parse_arguments([]).ssl
|
||||
|
||||
server_config.certfile = None
|
||||
server_config.certkey = None
|
||||
|
||||
assert server._parse_arguments(["--certfile", "bla"]).certfile == "bla"
|
||||
assert server._parse_arguments([]).certfile is None
|
||||
|
||||
assert server._parse_arguments(["--certkey", "blu"]).certkey == "blu"
|
||||
assert server._parse_arguments([]).certkey is None
|
||||
|
||||
assert server._parse_arguments(["-L"]).local
|
||||
assert server._parse_arguments(["--local"]).local
|
||||
|
||||
Reference in new issue
Block a user