Skip to content

Commit 8971fd4

Browse files
committed
basis
1 parent ca6a449 commit 8971fd4

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

api/specs/web-server/_tags_groups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def list_tag_groups(_path_params: Annotated[TagPathParams, Depends()]):
4242
async def create_tag_group(
4343
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
4444
):
45-
...
45+
"""Shares tag `tag_id` with an organization or user with `group_id` providing access-rights to it"""
4646

4747

4848
@router.put(
@@ -52,12 +52,12 @@ async def create_tag_group(
5252
async def replace_tag_groups(
5353
_path_params: Annotated[TagGroupPathParams, Depends()], _body: TagGroupCreate
5454
):
55-
...
55+
"""Replace access rights on tag for associated organization or user with `group_id`"""
5656

5757

5858
@router.delete(
5959
"/tags/{tag_id}/groups/{group_id}",
6060
status_code=status.HTTP_204_NO_CONTENT,
6161
)
6262
async def delete_tag_group(_path_params: Annotated[TagGroupPathParams, Depends()]):
63-
...
63+
"""Delete access rights on tag to an associated organization or user with `group_id`"""

services/web/server/tests/unit/with_dbs/03/tags/test_tags.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import sqlalchemy as sa
1212
from aiohttp.test_utils import TestClient
1313
from faker import Faker
14+
from models_library.groups import EVERYONE_GROUP_ID
1415
from models_library.projects_state import (
1516
ProjectLocked,
1617
ProjectRunningState,
@@ -151,7 +152,6 @@ async def test_read_tags(
151152
everybody_tag_id: int,
152153
):
153154
assert client.app
154-
155155
assert user_role == UserRole.USER
156156

157157
url = client.app.router["list_tags"].url_for()
@@ -177,7 +177,6 @@ async def test_create_and_update_tags(
177177
_clean_tags_table: None,
178178
):
179179
assert client.app
180-
181180
assert user_role == UserRole.USER
182181

183182
# (1) create tag
@@ -224,7 +223,6 @@ async def test_create_tags_with_order_index(
224223
_clean_tags_table: None,
225224
):
226225
assert client.app
227-
228226
assert user_role == UserRole.USER
229227

230228
# (1) create tags but set the order in reverse order of creation
@@ -276,3 +274,57 @@ async def test_create_tags_with_order_index(
276274
resp = await client.get(f"{url}")
277275
got, _ = await assert_status(resp, status.HTTP_200_OK)
278276
assert got == [*expected_tags[::-1], last_created]
277+
278+
279+
async def test_share_tags(
280+
client: TestClient,
281+
logged_user: UserInfoDict,
282+
user_role: UserRole,
283+
everybody_tag_id: int,
284+
_clean_tags_table: None,
285+
):
286+
assert client.app
287+
assert user_role == UserRole.USER
288+
289+
# CREATE
290+
url = client.app.router["create_tag"].url_for()
291+
resp = await client.post(
292+
f"{url}",
293+
json={"name": "shared", "color": "#fff"},
294+
)
295+
created, _ = await assert_status(resp, status.HTTP_200_OK)
296+
297+
# SHARE (all combinations)?
298+
url = client.app.router["create_tag_group"].url_for(
299+
tag_id=created["id"], group_id=f"{EVERYONE_GROUP_ID}"
300+
)
301+
resp = await client.post(
302+
f"{url}",
303+
json={"read": True, "write": False, "delete": False},
304+
)
305+
data, _ = await assert_status(resp, status.HTTP_200_OK)
306+
307+
# test only performed allowed combinations
308+
309+
# REPLACE SHARE to other combinations
310+
url = client.app.router["replace_tag_groups"].url_for(
311+
tag_id=created["id"], group_id=f"{EVERYONE_GROUP_ID}"
312+
)
313+
resp = await client.put(
314+
f"{url}",
315+
json={"read": True, "write": True, "delete": False},
316+
)
317+
data, _ = await assert_status(resp, status.HTTP_200_OK)
318+
319+
# test can perform new combinations
320+
321+
# DELETE share
322+
url = client.app.router["delete_tag_group"].url_for(
323+
tag_id=created["id"], group_id=f"{EVERYONE_GROUP_ID}"
324+
)
325+
resp = await client.delete(
326+
f"{url}",
327+
)
328+
data, _ = await assert_status(resp, status.HTTP_200_OK)
329+
330+
# test can do nothing

0 commit comments

Comments
 (0)