diff options
author | 2020-10-08 13:46:50 +0200 | |
---|---|---|
committer | 2020-10-08 15:46:29 +0200 | |
commit | 5ef0bbbda90428378a08d416481b90047f5ba870 (patch) | |
tree | 033870a5864fc9a7f2d172bb5cbf4c29660e4302 /src/onaptests/steps/reports_collection.py | |
parent | d1d44781c7d03c8794dd626184f77d9836264212 (diff) |
Add reporting page creation in pythonsdk-tests
Issue-ID: TEST-269
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Change-Id: I4ab0a2f7a1a1e98ae5d05166c6aa06212d24eeae
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'src/onaptests/steps/reports_collection.py')
-rw-r--r-- | src/onaptests/steps/reports_collection.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/onaptests/steps/reports_collection.py b/src/onaptests/steps/reports_collection.py index b61b571..62c0447 100644 --- a/src/onaptests/steps/reports_collection.py +++ b/src/onaptests/steps/reports_collection.py @@ -1,5 +1,7 @@ +import sys from typing import Dict - +from jinja2 import Environment, FileSystemLoader, select_autoescape +from onapsdk.configuration import settings class ReportsCollection: """Collection to store steps execution statuses.""" @@ -29,7 +31,34 @@ class ReportsCollection: """ report: Dict[str, str] = {} for element in self._collection[::-1]: - print(element) - print(type(element)) report.update(element) return report + + def generate_report(self) -> None: + step_list = self.report + failing_steps = [] + for step,status in step_list.items(): + if 'FAIL' in status: + failing_steps[step] = status + usecase = settings.SERVICE_NAME + try: + details = settings.SERVICE_DETAILS + except: + details = "" + try: + components = settings.SERVICE_COMPONENTS + except: + components = "" + log_path = settings.LOG_CONFIG['handlers']['file']['filename'] + jinja_env = Environment( + autoescape=select_autoescape(['html']), + loader=FileSystemLoader(sys.path[-1] + '/onaptests/templates/reporting')) + + jinja_env.get_template('reporting.html.j2').stream( + failing_steps=failing_steps, + steps=step_list, + usecase=usecase, + details=details, + components=components, + log_path=log_path).dump( + settings.REPORTING_FILE_PATH) |