Skip to content
Merged
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
40 changes: 34 additions & 6 deletions framework/python/src/test_orc/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ def zip_results(self, device, timestamp: str, profile):
LOCAL_DEVICE_REPORTS.replace("{device_folder}", device.device_folder),
timestamp, "test", device.mac_addr.replace(":", ""))

# report.json path
report_json_path = os.path.join(report_path, "report.json")

# Parse string timestamp
date_timestamp: datetime.datetime = datetime.strptime(
timestamp, "%Y-%m-%dT%H:%M:%S")
Expand All @@ -379,28 +382,53 @@ def zip_results(self, device, timestamp: str, profile):
if test_report is None:
return None

# Load the report.json into TestReport
if os.path.exists(report_json_path):
with open(report_json_path, "r", encoding="utf-8") as report_json_file:
report_json = json.load(report_json_file)
test_report = TestReport()
test_report.from_json(report_json)

# Copy the original report for comparison
original_report = copy.deepcopy(test_report)
test_report_copy = copy.deepcopy(test_report)

# Update the report with 'additional_info' field
test_report.update_device_profile(device.additional_info)

# Overwrite report only if additional_info has been updated
if original_report.to_json() != test_report.to_json():

# Write the json report
if test_report.to_json() != test_report_copy.to_json():

# Store the jinja templates
reload_templates = []

# Load the jinja templates
if os.path.isdir(report_path):
for dir_path, _, filenames in os.walk(report_path):
for filename in filenames:
try:
if filename.endswith(".j2.html"):
with open(os.path.join(dir_path, filename), "r",
encoding="utf-8") as f:
reload_templates.append(f.read())
except Exception as e:
LOGGER.debug(f"Could not read the file: {e}")

# Add the jinja templates to the report
test_report.add_module_templates(reload_templates)

# Rewrite the json report
with open(os.path.join(report_path, "report.json"),
"w",
encoding="utf-8") as f:
json.dump(test_report.to_json(), f, indent=2)

# Write the html report
# Rewrite the html report
with open(os.path.join(report_path, "report.html"),
"w",
encoding="utf-8") as f:
f.write(test_report.to_html())

# Write the pdf report
# Rewrite the pdf report
with open(os.path.join(report_path, "report.pdf"), "wb") as f:
f.write(test_report.to_pdf().getvalue())

Expand Down