File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1+ import random as rd
12from collections .abc import AsyncGenerator
23from typing import Any
34
@@ -192,12 +193,17 @@ async def test_queries_oauth(
192193 assert user .oauth_accounts [1 ].account_id == oauth_account2 ["account_id" ] # type: ignore
193194
194195 # Update OAuth account
196+ random_account_id = rd .choice (user .oauth_accounts ).id
197+
198+ def _get_account (_user : UserOAuth ):
199+ return next (acc for acc in _user .oauth_accounts if acc .id == random_account_id )
200+
195201 user = await dynamodb_user_db_oauth .update_oauth_account (
196202 user ,
197- user . oauth_accounts [ 0 ], # type: ignore
203+ _get_account ( user ),
198204 {"access_token" : "NEW_TOKEN" },
199205 )
200- assert user . oauth_accounts [ 0 ] .access_token == "NEW_TOKEN" # type: ignore
206+ assert _get_account ( user ) .access_token == "NEW_TOKEN" # type: ignore
201207
202208 #! IMPORTANT: Since DynamoDB uses eventual consistency, we need a small delay (e.g. `time.sleep(0.01)`) \
203209 #! to ensure the user was fully updated. In production, this should be negligible. \
@@ -208,7 +214,7 @@ async def test_queries_oauth(
208214 id_user = await dynamodb_user_db_oauth .get (user .id , instant_update = True )
209215 assert id_user is not None
210216 assert id_user .id == user .id
211- assert id_user . oauth_accounts [ 0 ] .access_token == "NEW_TOKEN" # type: ignore
217+ assert _get_account ( id_user ) .access_token == "NEW_TOKEN" # type: ignore
212218
213219 # Get by email
214220 email_user = await dynamodb_user_db_oauth .get_by_email (user_create ["email" ])
You can’t perform that action at this time.
0 commit comments