Skip to content

Commit e1c6a68

Browse files
committed
✨ Add test for updating wallet without thumbnail
1 parent 1d3792b commit e1c6a68

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

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)