Skip to content

Commit 0272554

Browse files
committed
fixes autoinclusion
1 parent 37d35db commit 0272554

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ class GroupCreate(InputSchema):
149149

150150
def to_model(self) -> StandardGroupCreate:
151151
data = _rename_keys(
152-
self.model_dump(mode="json", exclude_unset=True),
152+
self.model_dump(
153+
mode="json",
154+
# NOTE: intentionally inclusion_rules are not exposed to the REST api
155+
include={"label", "description", "thumbnail"},
156+
exclude_unset=True,
157+
),
153158
name_map={"label": "name"},
154159
)
155160
return StandardGroupCreate(**data)
@@ -162,7 +167,12 @@ class GroupUpdate(InputSchema):
162167

163168
def to_model(self) -> StandardGroupUpdate:
164169
data = _rename_keys(
165-
self.model_dump(mode="json", exclude_unset=True),
170+
self.model_dump(
171+
mode="json",
172+
# NOTE: intentionally inclusion_rules are not exposed to the REST api
173+
include={"label", "description", "thumbnail"},
174+
exclude_unset=True,
175+
),
166176
name_map={"label": "name"},
167177
)
168178
return StandardGroupUpdate(**data)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,20 @@ class StandardGroupCreate(BaseModel):
8282
name: str
8383
description: str | None = None
8484
thumbnail: str | None = None
85+
inclusion_rules: Annotated[
86+
dict[str, str],
87+
Field(
88+
default_factory=dict,
89+
description="Maps user's column and regular expression",
90+
),
91+
] = DEFAULT_FACTORY
8592

8693

8794
class StandardGroupUpdate(BaseModel):
8895
name: str | None = None
8996
description: str | None = None
9097
thumbnail: str | None = None
98+
inclusion_rules: dict[str, str] | None = None
9199

92100

93101
class GroupAtDB(Group):

packages/pytest-simcore/src/pytest_simcore/simcore_webserver_groups_fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def standard_groups_owner(
7474
"name": "SPARC",
7575
"description": "Stimulating Peripheral Activity to Relieve Conditions",
7676
"thumbnail": "https://commonfund.nih.gov/sites/default/files/sparc-image-homepage500px.png",
77-
"inclusionRules": {"email": r"@(sparc)+\.(io|com)$"},
77+
"inclusion_rules": {"email": r"@(sparc)+\.(io|com)$"},
7878
},
7979
)
8080
team_black_group = await _create_organization(
@@ -84,7 +84,7 @@ async def standard_groups_owner(
8484
"name": "team Black",
8585
"description": "THE incredible black team",
8686
"thumbnail": None,
87-
"inclusionRules": {"email": r"@(black)+\.(io|com)$"},
87+
"inclusion_rules": {"email": r"@(black)+\.(io|com)$"},
8888
},
8989
)
9090

services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_users.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ async def test_add_user_gets_added_to_group(
418418
user_role: UserRole,
419419
expected: ExpectedResponse,
420420
):
421+
421422
assert client.app
422423
async with AsyncExitStack() as users_stack:
423424
for email in (
425+
# SEE StandardGroupCreate.inclusion_rules in
426+
# packages/pytest-simcore/src/pytest_simcore/simcore_webserver_groups_fixtures.py
424427
425428
426429

0 commit comments

Comments
 (0)