Skip to content

Commit

Permalink
fix: serialize attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
huyenngn committed Nov 16, 2023
1 parent 3b52ee4 commit 63a350e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ venv.bak/
.spyderproject
.spyproject

# VS Code settings
.vscode/

# Rope project settings
.ropeproject

Expand Down
15 changes: 9 additions & 6 deletions polarion_rest_api_client/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ def calculate_checksum(self) -> str:

attachments = data.pop("attachments")

for attachment in attachments:
try:
attachment["content_bytes"] = attachment[
"content_bytes"
].decode("utf-8")
except AttributeError:
pass

data = dict(sorted(data.items()))

converted = json.dumps(data).encode("utf8")
converted_attachments = json.dumps(attachments).encode("utf8")
self._checksum = (
hashlib.sha256(converted).hexdigest()
+ " "
+ hashlib.sha256(converted_attachments).hexdigest()
)
self._checksum = hashlib.sha256(converted).hexdigest()
return self._checksum

def get_current_checksum(self) -> str | None:
Expand Down

0 comments on commit 63a350e

Please sign in to comment.