Skip to content

Commit

Permalink
fix : change logic for uploading attachments
Browse files Browse the repository at this point in the history
Now, the `upload_attachment` method won't return an error if the file is not
found.
  • Loading branch information
gibiw committed Sep 27, 2024
1 parent da11159 commit b6ef5f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
13 changes: 10 additions & 3 deletions qase-python-commons/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# [email protected]
# [email protected]

## What's new

Change logic for uploading attachments. Now, the `upload_attachment` method won't return an error if the file is not
found.

# [email protected]

## What's new

Expand Down Expand Up @@ -28,7 +35,7 @@ Support `suite` field in the test case model.

## What's new

Minor release that includes all changes from beta versions 3.1.0b*.
Minor release that includes all changes from beta versions 3.1.0b*.
Also added support for group parameters.

# [email protected]
Expand All @@ -45,7 +52,7 @@ HTTPSConnectionPool(host='api.qase.io', port=443): Max retries exceeded with url

## What's new

Reporters didn't send information about fields, like `title`, `description`, etc, to the Qase.
Reporters didn't send information about fields, like `title`, `description`, etc, to the Qase.
Now, the reporters will send all the information about the test case to the Qase.

# [email protected]
Expand Down
2 changes: 1 addition & 1 deletion qase-python-commons/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-python-commons"
version = "3.1.5"
version = "3.1.6"
description = "A library for Qase TestOps and Qase Report"
readme = "README.md"
authors = [{name = "Qase Team", email = "[email protected]"}]
Expand Down
12 changes: 8 additions & 4 deletions qase-python-commons/src/qase/commons/client/api_v1_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def _upload_attachment(self, project_code: str, attachment: Attachment) -> Union
return response.result

except Exception as e:
self.logger.log(f"Error at uploading attachment: {e}", "error")
raise ReporterException(e)
self.logger.log(f"Error at uploading attachment: {e}", "debug")
return None

def create_test_run(self, project_code: str, title: str, description: str, plan_id=None,
environment_id=None) -> str:
Expand Down Expand Up @@ -139,7 +139,9 @@ def _prepare_result(self, project_code: str, result: Result) -> Dict:
attached = []
if result.attachments:
for attachment in result.attachments:
attached.extend(self._upload_attachment(project_code, attachment))
attach_id = self._upload_attachment(project_code, attachment)
if attach_id:
attached.append(attach_id)

steps = []
for step in result.steps:
Expand Down Expand Up @@ -252,7 +254,9 @@ def _prepare_step(self, project_code: str, step: Step) -> Dict:
if step.attachments:
uploaded_attachments = []
for file in step.attachments:
uploaded_attachments.extend(self._upload_attachment(project_code, file))
attach_id = self._upload_attachment(project_code, file)
if attach_id:
uploaded_attachments.append(attach_id)
prepared_step['attachments'] = [attach.hash for attach in uploaded_attachments]

if step.steps:
Expand Down

0 comments on commit b6ef5f2

Please sign in to comment.