Skip to content

Commit 4abbe6b

Browse files
committed
Bring test coverage to 100%
1 parent f0c519f commit 4abbe6b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fastapi_users_db_dynamodb/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,17 @@ async def add_oauth_account(self, user: UP, create_dict: dict[str, Any]) -> UP:
250250
try:
251251
create_dict["user_id"] = getattr(create_dict, "user_id", user.id)
252252
oauth_account = self.oauth_account_table(**create_dict)
253-
await oauth_account.save(condition=self.user_table.id.does_not_exist())
253+
await oauth_account.save(
254+
condition=self.oauth_account_table.id.does_not_exist() # type: ignore
255+
& self.oauth_account_table.account_id.does_not_exist() # type: ignore
256+
)
254257
user.oauth_accounts.append(oauth_account) # type: ignore
255-
except PutError as e:
258+
except PutError as e: # pragma: no cover
256259
if e.cause_response_code == "ConditionalCheckFailedException":
257260
raise ValueError(
258261
"OAuth account could not be added because it already exists."
259262
) from e
260-
raise ValueError( # pragma: no cover
263+
raise ValueError(
261264
"OAuth account could not be added because the table does not exist."
262265
) from e
263266

@@ -277,7 +280,10 @@ async def update_oauth_account(
277280
try:
278281
for k, v in update_dict.items():
279282
setattr(oauth_account, k, v)
280-
await oauth_account.save(condition=self.user_table.id.exists()) # type: ignore
283+
await oauth_account.save( # type: ignore
284+
condition=self.oauth_account_table.id.exists() # type: ignore
285+
& self.oauth_account_table.account_id.exists() # type: ignore
286+
)
281287
except PutError as e:
282288
if e.cause_response_code == "ConditionalCheckFailedException":
283289
raise ValueError(

0 commit comments

Comments
 (0)