diff --git a/framework/python/src/common/device.py b/framework/python/src/common/device.py index f008570d9..a39d75c76 100644 --- a/framework/python/src/common/device.py +++ b/framework/python/src/common/device.py @@ -59,6 +59,7 @@ def to_dict(self): device_json['model'] = self.model if self.firmware is not None: device_json['firmware'] = self.firmware + device_json['test_modules'] = self.test_modules return device_json def to_config_json(self): diff --git a/framework/python/src/common/testreport.py b/framework/python/src/common/testreport.py index c88a7bfae..647cb10e5 100644 --- a/framework/python/src/common/testreport.py +++ b/framework/python/src/common/testreport.py @@ -17,6 +17,7 @@ from datetime import datetime from weasyprint import HTML from io import BytesIO +from common import util import base64 import os @@ -94,6 +95,9 @@ def from_json(self, json_file): if 'firmware' in json_file['device']: self._device['firmware'] = json_file['device']['firmware'] + if 'test_modules' in json_file['device']: + self._device['test_modules'] = json_file['device']['test_modules'] + 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) @@ -285,12 +289,52 @@ def generate_summary(self, json_data): mac, trailing_space=False) + # Add device configuration + summary += ''' +
+
+ Device Configuration +
+ ''' + + if 'test_modules' in json_data['device']: + + sorted_modules = {} + + for test_module in json_data['device']['test_modules']: + if 'enabled' in json_data['device']['test_modules'][test_module]: + sorted_modules[test_module] = json_data['device']['test_modules'][ + test_module]['enabled'] + + # Sort the modules by enabled first + sorted_modules = sorted(sorted_modules.items(), + key=lambda x:x[1], + reverse=True) + + for module in sorted_modules: + summary += self.generate_device_module_label( + module[0], + module[1] + ) + + summary += '
' + # Add the result summary summary += self.generate_result_summary(json_data) summary += '\n' return summary + def generate_device_module_label(self, module, enabled): + label = '
' + if enabled: + label += '' + else: + label += '' + label += util.get_module_display_name(module) + label += '
' + return label + def generate_result_summary(self,json_data): if json_data['status'] == 'Compliant': result_summary = '''