Skip to content

Commit 8e89260

Browse files
committed
fixes tests
1 parent badef8f commit 8e89260

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

packages/models-library/src/models_library/groups.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
TypedDict,
1010
)
1111

12-
from .basic_types import IDStr
13-
from .users import UserID
12+
from .users import UserID, UserNameID
1413
from .utils.common_validators import create_enums_pre_validator
1514

1615
EVERYONE_GROUP_ID: Final[int] = 1
@@ -99,10 +98,10 @@ class GroupsByTypeTuple(NamedTuple):
9998
class GroupMember(BaseModel):
10099
# identifiers
101100
id: UserID
102-
name: IDStr
103101
primary_gid: GroupID
104102

105103
# private profile
104+
name: UserNameID | None
106105
email: EmailStr | None
107106
first_name: str | None
108107
last_name: str | None

services/web/server/tests/unit/with_dbs/03/test_users.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def app_environment(
6363

6464
@pytest.fixture
6565
def partial_first_name() -> str:
66-
return "James"
66+
return "Jaimito"
6767

6868

6969
@pytest.fixture
@@ -145,9 +145,9 @@ async def test_search_users_by_partial_fullname(
145145
logged_user: UserInfoDict,
146146
client: TestClient,
147147
partial_first_name: str,
148-
public_user: UserInfoDict,
149-
semi_private_user: UserInfoDict,
150148
private_user: UserInfoDict,
149+
semi_private_user: UserInfoDict,
150+
public_user: UserInfoDict,
151151
):
152152
assert client.app
153153
assert user_role.value == logged_user["role"]
@@ -177,9 +177,9 @@ async def test_search_users_by_partial_fullname(
177177

178178
@pytest.mark.parametrize("user_role", [UserRole.USER])
179179
async def test_search_users_by_partial_email(
180+
user_role: UserRole,
180181
logged_user: UserInfoDict,
181182
client: TestClient,
182-
user_role: UserRole,
183183
partial_email: str,
184184
public_user: UserInfoDict,
185185
semi_private_user: UserInfoDict,
@@ -216,11 +216,12 @@ async def test_search_users_by_partial_email(
216216
await assert_status(resp, status.HTTP_403_FORBIDDEN)
217217

218218

219+
@pytest.mark.parametrize("user_role", [UserRole.USER])
219220
async def test_search_users_by_partial_username(
221+
user_role: UserRole,
220222
logged_user: UserInfoDict,
221223
client: TestClient,
222224
partial_username: str,
223-
user_role: UserRole,
224225
public_user: UserInfoDict,
225226
semi_private_user: UserInfoDict,
226227
private_user: UserInfoDict,
@@ -249,18 +250,18 @@ async def test_search_users_by_partial_username(
249250
index = (index + 1) % 2
250251
assert found[index].user_name == semi_private_user["name"]
251252
assert found[index].email is None
252-
assert found[index].first_name is None
253-
assert found[index].last_name is None
253+
assert found[index].first_name == semi_private_user.get("first_name")
254+
assert found[index].last_name == semi_private_user.get("last_name")
254255

255256

256257
@pytest.mark.acceptance_test(
257258
"https://github.com/ITISFoundation/osparc-issues/issues/1779"
258259
)
259260
@pytest.mark.parametrize("user_role", [UserRole.USER])
260261
async def test_get_user_by_group_id(
262+
user_role: UserRole,
261263
logged_user: UserInfoDict,
262264
client: TestClient,
263-
user_role: UserRole,
264265
public_user: UserInfoDict,
265266
private_user: UserInfoDict,
266267
):
@@ -329,9 +330,9 @@ async def test_access_rights_on_get_profile(
329330
],
330331
)
331332
async def test_access_update_profile(
333+
user_role: UserRole,
332334
logged_user: UserInfoDict,
333335
client: TestClient,
334-
user_role: UserRole,
335336
expected: HTTPStatus,
336337
):
337338
assert client.app
@@ -345,9 +346,9 @@ async def test_access_update_profile(
345346

346347
@pytest.mark.parametrize("user_role", [UserRole.USER])
347348
async def test_get_profile(
349+
user_role: UserRole,
348350
logged_user: UserInfoDict,
349351
client: TestClient,
350-
user_role: UserRole,
351352
primary_group: dict[str, Any],
352353
standard_groups: list[dict[str, Any]],
353354
all_group: dict[str, str],
@@ -393,9 +394,9 @@ async def test_get_profile(
393394

394395
@pytest.mark.parametrize("user_role", [UserRole.USER])
395396
async def test_update_profile(
397+
user_role: UserRole,
396398
logged_user: UserInfoDict,
397399
client: TestClient,
398-
user_role: UserRole,
399400
):
400401
assert client.app
401402

@@ -434,9 +435,9 @@ def _copy(data: dict, exclude: set) -> dict:
434435

435436
@pytest.mark.parametrize("user_role", [UserRole.USER])
436437
async def test_profile_workflow(
438+
user_role: UserRole,
437439
logged_user: UserInfoDict,
438440
client: TestClient,
439-
user_role: UserRole,
440441
):
441442
assert client.app
442443

@@ -476,9 +477,9 @@ async def test_profile_workflow(
476477
@pytest.mark.parametrize("user_role", [UserRole.USER])
477478
@pytest.mark.parametrize("invalid_username", ["", "_foo", "superadmin", "foo..-123"])
478479
async def test_update_wrong_user_name(
480+
user_role: UserRole,
479481
logged_user: UserInfoDict,
480482
client: TestClient,
481-
user_role: UserRole,
482483
invalid_username: str,
483484
):
484485
assert client.app
@@ -495,10 +496,10 @@ async def test_update_wrong_user_name(
495496

496497
@pytest.mark.parametrize("user_role", [UserRole.USER])
497498
async def test_update_existing_user_name(
499+
user_role: UserRole,
498500
user: UserInfoDict,
499501
logged_user: UserInfoDict,
500502
client: TestClient,
501-
user_role: UserRole,
502503
):
503504
assert client.app
504505

0 commit comments

Comments
 (0)