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
32 changes: 22 additions & 10 deletions framework/python/src/common/testreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import base64
import os
from test_orc.test_case import TestCase
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
from collections import OrderedDict

DATE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
Expand All @@ -42,6 +42,8 @@
report_resource_dir = os.path.join(root_dir, RESOURCES_DIR)

test_run_img_file = os.path.join(report_resource_dir, 'testrun.png')
qualification_icon = os.path.join(report_resource_dir, 'qualification-icon.png')
pilot_icon = os.path.join(report_resource_dir, 'pilot-icon.png')


class TestReport():
Expand Down Expand Up @@ -153,6 +155,9 @@ def from_json(self, json_file):
if 'test_pack' in json_file['device']:
self._device['test_pack'] = json_file['device']['test_pack']

if 'additional_info' in json_file['device']:
self._device['device_profile'] = json_file['device']['additional_info']

self._status = json_file['status']
self._started = datetime.strptime(json_file['started'], DATE_TIME_FORMAT)
self._finished = datetime.strptime(json_file['finished'], DATE_TIME_FORMAT)
Expand Down Expand Up @@ -194,13 +199,8 @@ def to_pdf(self):
def to_html(self):

# Jinja template
with open(os.path.join(report_resource_dir, TEST_REPORT_TEMPLATE),
'r',
encoding='UTF-8'
) as template_file:
template = Template(template_file.read())

# Load styles
template_env = Environment(loader=FileSystemLoader(report_resource_dir))
template = template_env.get_template(TEST_REPORT_TEMPLATE)
with open(os.path.join(report_resource_dir,
TEST_REPORT_STYLES),
'r',
Expand All @@ -211,8 +211,15 @@ def to_html(self):
# Load Testrun logo to base64
with open(test_run_img_file, 'rb') as f:
logo = base64.b64encode(f.read()).decode('utf-8')

json_data=self.to_json()

# Icons
with open(qualification_icon, 'rb') as f:
icon_qualification = base64.b64encode(f.read()).decode('utf-8')
with open(pilot_icon, 'rb') as f:
icon_pilot = base64.b64encode(f.read()).decode('utf-8')

# Convert the timestamp strings to datetime objects
start_time = datetime.strptime(json_data['started'], '%Y-%m-%d %H:%M:%S')
end_time = datetime.strptime(json_data['finished'], '%Y-%m-%d %H:%M:%S')
Expand All @@ -234,13 +241,18 @@ def to_html(self):

module_reports = self._get_module_pages()
pages_num = self._pages_num(json_data)
total_pages = pages_num + len(module_reports)

total_pages = pages_num + len(module_reports) + 1
if len(steps_to_resolve) > 0:
total_pages += 1
if (len(optional_steps_to_resolve) > 0
and json_data['device']['test_pack'] == 'Pilot Assessment'
):
total_pages += 1

return template.render(styles=styles,
logo=logo,
icon_qualification=icon_qualification,
icon_pilot=icon_pilot,
version=self._version,
json_data=json_data,
device=json_data['device'],
Expand Down
Loading