aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/reports_collection.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/onaptests/steps/reports_collection.py')
-rw-r--r--src/onaptests/steps/reports_collection.py35
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)