Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions qase-python-commons/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# qase-python-commons@5.0.2

## What's new

- Aligned report mode with specification schema:
- Renamed output file from `report.json` to `run.json`
- Replaced `broken` status with `blocked` in run statistics
- Added automatic conversion of all step data types to TEXT format for report serialization

# qase-python-commons@5.0.1

## 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 = "5.0.1"
version = "5.0.2"
description = "A library for Qase TestOps and Qase Report"
readme = "README.md"
authors = [{name = "Qase Team", email = "support@qase.io"}]
Expand Down
6 changes: 3 additions & 3 deletions qase-python-commons/src/qase/commons/models/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self) -> None:
self.passed = 0
self.failed = 0
self.skipped = 0
self.broken = 0
self.blocked = 0
self.invalid = 0
self.muted = 0
self.total = 0
Expand All @@ -36,8 +36,8 @@ def track(self, result: dict):
self.failed += 1
elif status == "skipped":
self.skipped += 1
elif status == "broken":
self.broken += 1
elif status == "blocked":
self.blocked += 1
elif status == "invalid":
self.invalid += 1
self.total += 1
Expand Down
58 changes: 57 additions & 1 deletion qase-python-commons/src/qase/commons/reporters/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,63 @@
import json
import re
from ..models import Result, Run, Attachment
from ..models.step import Step, StepType, StepTextData
from .. import QaseUtils, Logger
from ..models.config.connection import Format
from ..models.config.qaseconfig import QaseConfig


def _convert_step_data_to_text(step: Step) -> None:
"""Convert step data to TEXT format for report serialization."""
if step.data is None:
return

step_type = step.step_type
data = step.data

if step_type == StepType.TEXT:
# Already in TEXT format, no conversion needed
pass
elif step_type == StepType.ASSERT:
step.data = StepTextData(
action=f"Assert: {data.message}",
expected_result=str(data.expected)
)
step.data.input_data = str(data.actual)
elif step_type == StepType.GHERKIN:
step.data = StepTextData(
action=f"{data.keyword} {data.name}",
expected_result=None
)
step.data.input_data = data.data
elif step_type == StepType.REQUEST:
step.data = StepTextData(
action=f"{data.request_method} {data.request_url}",
expected_result=f"Status: {data.status_code}" if data.status_code else None
)
step.data.input_data = data.request_body
elif step_type == StepType.DB_QUERY:
step.data = StepTextData(
action=f"SQL: {data.query}",
expected_result=data.expected_result
)
step.data.input_data = data.connection_info
elif step_type == StepType.SLEEP:
step.data = StepTextData(
action=f"Sleep {data.duration}ms",
expected_result=None
)
step.data.input_data = None

# Set step_type to TEXT after conversion
step.step_type = StepType.TEXT

# Recursively convert nested steps
if step.steps:
for nested_step in step.steps:
_convert_step_data_to_text(nested_step)


class QaseReport:
def __init__(
self,
Expand Down Expand Up @@ -91,6 +143,10 @@ def _persist_attachments_in_steps(self, steps: list):

# Method saves result to a file
def _store_result(self, result: Result):
# Convert all step data to TEXT format for report
if result.steps:
for step in result.steps:
_convert_step_data_to_text(step)
self._store_object(result, self.report_path + "/results/", result.id)

def _check_report_path(self):
Expand Down Expand Up @@ -121,7 +177,7 @@ def _compile_report(self):

run.add_host_data(QaseUtils.get_host_data())

self._store_object(run, self.report_path, "report")
self._store_object(run, self.report_path, "run")

# Saves a model to a file
def _store_object(self, object, path, filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def test_run_stats():
assert stats.passed == 0
assert stats.failed == 0
assert stats.skipped == 0
assert stats.broken == 0
assert stats.blocked == 0
assert stats.invalid == 0
assert stats.muted == 0
assert stats.total == 0

Expand Down