Skip to content

Commit

Permalink
Refactored get instead of literal dict retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemanja Trivic committed Feb 28, 2024
1 parent f0e8d3c commit 9bc9cdc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/flask_session/dynamodb/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def __init__(

def _retrieve_session_data(self, store_id: str) -> Optional[dict]:
# Get the saved session (document) from the database
document = self.store.get_item(Key={"id": store_id})["Item"]
document = self.store.get_item(Key={"id": store_id}).get("Item")
if document:
serialized_session_data = want_bytes(document["val"].value)
serialized_session_data = want_bytes(document.get("val").value)
return self.serializer.decode(serialized_session_data)
return None

Expand Down
8 changes: 4 additions & 4 deletions tests/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ def setup_dynamodb(self):
try:
scan = self.store.scan()
with self.store.batch_writer() as batch:
for each in scan["Items"]:
for each in scan.get("Items"):
batch.delete_item(
Key={
"id": each["id"],
"id": each.get("id"),
}
)
yield
finally:
scan = self.store.scan()
with self.store.batch_writer() as batch:
for each in scan["Items"]:
for each in scan.get("Items"):
batch.delete_item(
Key={
"id": each["id"],
"id": each.get("id"),
}
)
pass
Expand Down

0 comments on commit 9bc9cdc

Please sign in to comment.