Skip to content

Commit fa9d3a0

Browse files
authored
🐛 web-api: wallet update operation has now optional thumbnail (#7736)
1 parent 78abf4b commit fa9d3a0

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ class WalletGetPermissions(WalletGet):
7474
)
7575

7676

77-
class CreateWalletBodyParams(OutputSchema):
77+
class CreateWalletBodyParams(InputSchema):
7878
name: str
7979
description: str | None = None
8080
thumbnail: str | None = None
8181

8282

83-
class PutWalletBodyParams(OutputSchema):
83+
class PutWalletBodyParams(InputSchema):
8484
name: str
8585
description: str | None
86-
thumbnail: str | None
86+
thumbnail: str | None = None
8787
status: WalletStatus
8888

8989

services/web/server/setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ commit_args = --no-verify
1313
addopts = --strict-markers
1414
asyncio_mode = auto
1515
asyncio_default_fixture_loop_scope = function
16-
markers =
16+
markers =
1717
slow: marks tests as slow (deselect with '-m "not slow"')
1818
acceptance_test: "marks tests as 'acceptance tests' i.e. does the system do what the user expects? Typically those are workflows."
1919
testit: "marks test to run during development"
2020
heavy_load: "mark tests that require large amount of data"
2121

2222
[mypy]
23-
plugins =
23+
plugins =
2424
pydantic.mypy
2525
sqlalchemy.ext.mypy.plugin

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15346,7 +15346,6 @@ components:
1534615346
required:
1534715347
- name
1534815348
- description
15349-
- thumbnail
1535015349
- status
1535115350
title: PutWalletBodyParams
1535215351
RegisterBody:

services/web/server/tests/unit/with_dbs/04/wallets/test_wallets.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,61 @@ async def test_get_default_wallet_access_rights(
258258
status.HTTP_401_UNAUTHORIZED,
259259
status.HTTP_403_FORBIDDEN,
260260
), f"{error}"
261+
262+
263+
@pytest.mark.parametrize("user_role,expected", [(UserRole.USER, status.HTTP_200_OK)])
264+
async def test_update_wallet_without_thumbnail(
265+
client: TestClient,
266+
logged_user: UserInfoDict,
267+
expected: HTTPStatus,
268+
wallets_clean_db: AsyncIterator[None],
269+
mock_rut_sum_total_available_credits_in_the_wallet: mock.Mock,
270+
):
271+
assert client.app
272+
273+
# Create a wallet first
274+
url = client.app.router["create_wallet"].url_for()
275+
resp = await client.post(
276+
url.path,
277+
json={
278+
"name": "Test wallet",
279+
"description": "Test description",
280+
"thumbnail": "Initial thumbnail",
281+
},
282+
)
283+
created_wallet, _ = await assert_status(resp, status.HTTP_201_CREATED)
284+
assert created_wallet["thumbnail"] == "Initial thumbnail"
285+
286+
# Update the wallet without a thumbnail in the request body
287+
url = client.app.router["update_wallet"].url_for(
288+
wallet_id=f"{created_wallet['walletId']}"
289+
)
290+
resp = await client.put(
291+
url.path,
292+
json={
293+
"name": "Updated wallet name",
294+
"description": "Updated description",
295+
"status": "ACTIVE",
296+
},
297+
)
298+
updated_wallet, _ = await assert_status(resp, status.HTTP_200_OK)
299+
300+
# Verify that the thumbnail is set to None when not provided in the request
301+
assert updated_wallet["walletId"] == created_wallet["walletId"]
302+
assert updated_wallet["name"] == "Updated wallet name"
303+
assert updated_wallet["description"] == "Updated description"
304+
assert (
305+
updated_wallet["thumbnail"] is None
306+
) # Thumbnail should be None when not provided
307+
assert updated_wallet["status"] == "ACTIVE"
308+
309+
# Get the wallet to verify the changes persisted
310+
url = client.app.router["get_wallet"].url_for(
311+
wallet_id=f"{created_wallet['walletId']}"
312+
)
313+
resp = await client.get(url.path)
314+
fetched_wallet, _ = await assert_status(resp, status.HTTP_200_OK)
315+
316+
assert (
317+
fetched_wallet["thumbnail"] is None
318+
) # Confirm thumbnail is None in the database

0 commit comments

Comments
 (0)