Skip to content

Commit 654febf

Browse files
committed
updates tests
1 parent 9803414 commit 654febf

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
PreUserProfile,
3939
UserProfile,
4040
)
41-
from simcore_service_webserver.users.schemas import ProfileGet, ProfileUpdate
41+
from simcore_service_webserver.users.schemas import ProfileGet
4242

4343

4444
@pytest.fixture
@@ -168,19 +168,34 @@ async def test_update_profile(
168168
):
169169
assert client.app
170170

171+
resp = await client.get("/v0/me")
172+
data, _ = await assert_status(resp, status.HTTP_200_OK)
173+
174+
assert data["role"] == user_role.name
175+
before = deepcopy(data)
176+
171177
url = client.app.router["update_my_profile"].url_for()
172178
assert url.path == "/v0/me"
173-
resp = await client.patch(f"{url}", json={"last_name": "Foo"})
179+
resp = await client.patch(
180+
f"{url}",
181+
json={
182+
"last_name": "Foo",
183+
},
184+
)
174185
_, error = await assert_status(resp, status.HTTP_204_NO_CONTENT)
175186

176187
assert not error
177-
resp = await client.get(f"{url}")
188+
189+
resp = await client.get("/v0/me")
178190
data, _ = await assert_status(resp, status.HTTP_200_OK)
179191

180-
# This is a PUT! i.e. full replace of profile variable fields!
181-
assert data["first_name"] == ProfileUpdate.model_fields["first_name"].default
182192
assert data["last_name"] == "Foo"
183-
assert data["role"] == user_role.name
193+
194+
def _copy(data: dict, exclude: set) -> dict:
195+
return {k: v for k, v in data.items() if k not in exclude}
196+
197+
exclude = {"last_name"}
198+
assert _copy(data, exclude) == _copy(before, exclude)
184199

185200

186201
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)