|
38 | 38 | PreUserProfile, |
39 | 39 | UserProfile, |
40 | 40 | ) |
41 | | -from simcore_service_webserver.users.schemas import ProfileGet, ProfileUpdate |
| 41 | +from simcore_service_webserver.users.schemas import ProfileGet |
42 | 42 |
|
43 | 43 |
|
44 | 44 | @pytest.fixture |
@@ -168,19 +168,34 @@ async def test_update_profile( |
168 | 168 | ): |
169 | 169 | assert client.app |
170 | 170 |
|
| 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 | + |
171 | 177 | url = client.app.router["update_my_profile"].url_for() |
172 | 178 | 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 | + ) |
174 | 185 | _, error = await assert_status(resp, status.HTTP_204_NO_CONTENT) |
175 | 186 |
|
176 | 187 | assert not error |
177 | | - resp = await client.get(f"{url}") |
| 188 | + |
| 189 | + resp = await client.get("/v0/me") |
178 | 190 | data, _ = await assert_status(resp, status.HTTP_200_OK) |
179 | 191 |
|
180 | | - # This is a PUT! i.e. full replace of profile variable fields! |
181 | | - assert data["first_name"] == ProfileUpdate.model_fields["first_name"].default |
182 | 192 | 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) |
184 | 199 |
|
185 | 200 |
|
186 | 201 | @pytest.mark.parametrize( |
|
0 commit comments