|
3 | 3 | # pylint: disable=unused-variable |
4 | 4 | # pylint: disable=too-many-arguments |
5 | 5 |
|
6 | | -from collections.abc import Awaitable, Callable |
7 | | -from typing import Any |
8 | 6 | from uuid import UUID |
9 | 7 |
|
10 | 8 | import pytest |
11 | 9 | from aiohttp.test_utils import TestClient |
| 10 | +from common_library.users_enums import UserRole |
12 | 11 | from pytest_simcore.helpers.webserver_login import UserInfoDict |
13 | 12 | from simcore_service_webserver.projects import ( |
14 | 13 | _projects_db as projects_service_repository, |
|
17 | 16 | from simcore_service_webserver.projects.models import ProjectDict |
18 | 17 |
|
19 | 18 |
|
| 19 | +@pytest.fixture |
| 20 | +def user_role() -> UserRole: |
| 21 | + return UserRole.USER |
| 22 | + |
| 23 | + |
20 | 24 | async def test_get_project( |
21 | 25 | client: TestClient, |
22 | 26 | logged_user: UserInfoDict, |
23 | 27 | user_project: ProjectDict, |
24 | | - insert_project_in_db: Callable[..., Awaitable[dict[str, Any]]], |
25 | 28 | ): |
26 | 29 | assert client.app |
27 | 30 |
|
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"]) |
| 31 | + # Get valid project |
| 32 | + got = await projects_service_repository.get_project( |
| 33 | + client.app, project_uuid=user_project["uuid"] |
34 | 34 | ) |
35 | 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"] |
| 36 | + assert got.uuid == UUID(user_project["uuid"]) |
| 37 | + assert got.name == user_project["name"] |
| 38 | + assert got.description == user_project["description"] |
40 | 39 |
|
41 | | - # Test retrieving a non-existent project |
| 40 | + # Get non-existent project |
42 | 41 | non_existent_project_uuid = UUID("00000000-0000-0000-0000-000000000000") |
43 | 42 | with pytest.raises(ProjectNotFoundError): |
44 | 43 | await projects_service_repository.get_project( |
|
0 commit comments