-
Notifications
You must be signed in to change notification settings - Fork 32
🐛 fix list_users_in_group introduced in previous PR
#8249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
matusdrobuliak66
merged 6 commits into
ITISFoundation:master
from
matusdrobuliak66:fix-support-center
Aug 22, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c7f9761
fix
matusdrobuliak66 6cd4815
Merge branch 'master' into fix-support-center
matusdrobuliak66 f892101
fix
matusdrobuliak66 e940a29
Merge branch 'fix-support-center' of github.com:matusdrobuliak66/ospa…
matusdrobuliak66 049cd74
fix
matusdrobuliak66 fb42095
fix
matusdrobuliak66 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
services/web/server/tests/unit/with_dbs/01/groups/test_groups_repository.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # pylint: disable=redefined-outer-name | ||
| # pylint: disable=too-many-arguments | ||
| # pylint: disable=unused-argument | ||
| # pylint: disable=unused-variable | ||
|
|
||
| from collections.abc import AsyncGenerator, Callable, Coroutine | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
| from aiohttp.test_utils import TestClient | ||
| from models_library.groups import GroupMember, StandardGroupCreate | ||
| from pytest_simcore.helpers.webserver_users import UserInfoDict | ||
| from simcore_postgres_database.models.users import UserRole | ||
| from simcore_service_webserver.groups import _groups_repository | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def create_test_group( | ||
| client: TestClient, logged_user: UserInfoDict | ||
| ) -> AsyncGenerator[Callable[..., Coroutine[Any, Any, Any]], None]: | ||
| """Fixture that creates a standard group and ensures cleanup.""" | ||
| created_groups = [] | ||
|
|
||
| async def _create_group( | ||
| name: str = "Test Group", | ||
| description: str = "A test group", | ||
| thumbnail: str | None = None, | ||
| ): | ||
| group, _ = await _groups_repository.create_standard_group( | ||
| app=client.app, | ||
| user_id=logged_user["id"], | ||
| create=StandardGroupCreate( | ||
| name=name, | ||
| description=description, | ||
| thumbnail=thumbnail, | ||
| ), | ||
| ) | ||
| created_groups.append(group) | ||
| return group | ||
|
|
||
| yield _create_group | ||
|
|
||
| # Cleanup all created groups | ||
| for group in created_groups: | ||
| await _groups_repository.delete_standard_group( | ||
| app=client.app, user_id=logged_user["id"], group_id=group.gid | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("user_role", [UserRole.USER]) | ||
| async def test_list_users_in_group_owner_only( | ||
| client: TestClient, | ||
| user_role: UserRole, | ||
| logged_user: UserInfoDict, | ||
| create_test_group: Callable[..., Coroutine[Any, Any, Any]], | ||
| ): | ||
| """Test list_users_in_group returns only the owner for a new group.""" | ||
| assert client.app | ||
|
|
||
| # Create a standard group | ||
| group = await create_test_group( | ||
| name="Test Owner Only Group", | ||
| description="A test group to check owner-only user list", | ||
| ) | ||
|
|
||
| # List users in the group - should only contain the owner | ||
| users_in_group = await _groups_repository.list_users_in_group( | ||
| app=client.app, group_id=group.gid | ||
| ) | ||
|
|
||
| # Should contain exactly one user (the owner) | ||
| assert len(users_in_group) == 1 | ||
| assert isinstance(users_in_group[0], GroupMember) | ||
| assert users_in_group[0].id == logged_user["id"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.