Skip to content

Commit e831310

Browse files
committed
drafts tests
1 parent f263116 commit e831310

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments
5+
6+
from collections.abc import Awaitable, Callable
7+
from typing import Any
8+
from uuid import UUID
9+
10+
import pytest
11+
from aiohttp.test_utils import TestClient
12+
from pytest_simcore.helpers.webserver_login import UserInfoDict
13+
from simcore_service_webserver.projects import (
14+
_projects_db as projects_service_repository,
15+
)
16+
from simcore_service_webserver.projects.exceptions import ProjectNotFoundError
17+
from simcore_service_webserver.projects.models import ProjectDict
18+
19+
20+
async def test_get_project(
21+
client: TestClient,
22+
logged_user: UserInfoDict,
23+
user_project: ProjectDict,
24+
insert_project_in_db: Callable[..., Awaitable[dict[str, Any]]],
25+
):
26+
assert client.app
27+
28+
# Insert a project into the database
29+
new_project = await insert_project_in_db(user_project, user_id=logged_user["id"])
30+
31+
# Retrieve the project using the repository function
32+
retrieved_project = await projects_service_repository.get_project(
33+
client.app, project_uuid=UUID(new_project["uuid"])
34+
)
35+
36+
# Validate the retrieved project
37+
assert retrieved_project.uuid == new_project["uuid"]
38+
assert retrieved_project.name == new_project["name"]
39+
assert retrieved_project.description == new_project["description"]
40+
41+
# Test retrieving a non-existent project
42+
non_existent_project_uuid = UUID("00000000-0000-0000-0000-000000000000")
43+
with pytest.raises(ProjectNotFoundError):
44+
await projects_service_repository.get_project(
45+
client.app, project_uuid=non_existent_project_uuid
46+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
# pylint: disable=unused-variable
4+
# pylint: disable=too-many-arguments

0 commit comments

Comments
 (0)