Skip to content

Commit

Permalink
fix : an issue with the upload_attachment method
Browse files Browse the repository at this point in the history
```log
attached.extend(self._upload_attachment(project_code, attachment))
TypeError: 'NoneType' object is not iterable
```
  • Loading branch information
gibiw committed Nov 22, 2024
1 parent c453ef4 commit 14b3134
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
11 changes: 11 additions & 0 deletions qase-python-commons/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# [email protected]

## What's new

Fixed an issue with the `upload_attachment` method:

```log
attached.extend(self._upload_attachment(project_code, attachment))
TypeError: 'NoneType' object is not iterable
```

# [email protected]

## What's new
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.2.1"
version = "3.2.2"
description = "A library for Qase TestOps and Qase Report"
readme = "README.md"
authors = [{name = "Qase Team", email = "[email protected]"}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ 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}", "debug")
self.logger.log(f"Error at uploading attachment: {e}", "error")
return None

def create_test_run(self, project_code: str, title: str, description: str, plan_id=None,
Expand Down
22 changes: 20 additions & 2 deletions qase-python-commons/src/qase/commons/client/api_v2_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .api_v1_client import ApiV1Client
from .. import Logger
from ..exceptions.reporter import ReporterException
from ..models.config.framework import Video, Trace
from ..models import Attachment, Result
from ..models.config.qaseconfig import QaseConfig
from ..models.step import StepType, Step
Expand Down Expand Up @@ -56,7 +57,11 @@ def _prepare_result(self, project_code: str, result: Result) -> ResultCreate:
attached = []
if result.attachments:
for attachment in result.attachments:
attached.extend(self._upload_attachment(project_code, attachment))
if self.__should_skip_attachment(attachment, result):
continue
attach_id = self._upload_attachment(project_code, attachment)
if attach_id:
attached.extend(attach_id)

steps = []
for step in result.steps:
Expand Down Expand Up @@ -142,7 +147,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.extend(attach_id)

prepared_step['execution']['attachments'] = [attach.hash for attach in uploaded_attachments]

Expand All @@ -154,3 +161,14 @@ def _prepare_step(self, project_code: str, step: Step) -> Dict:
except Exception as e:
self.logger.log(f"Error at preparing step: {e}", "error")
raise ReporterException(e)

def __should_skip_attachment(self, attachment, result):
if (self.config.framework.playwright.video == Video.failed and
result.execution.status != 'failed' and
attachment.file_name == 'video.webm'):
return True
if (self.config.framework.playwright.trace == Trace.failed and
result.execution.status != 'failed' and
attachment.file_name == 'trace.zip'):
return True
return False

0 comments on commit 14b3134

Please sign in to comment.