aboutsummaryrefslogtreecommitdiffstats
path: root/sfc/lib/results.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-12-13 12:31:39 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-12-15 12:37:52 +0100
commitacf339f2840d0fe7a46187a0597704cf5b486214 (patch)
treede114d6482bcd7cfd9d057f756d8b6f8864911cb /sfc/lib/results.py
parent1350624dbcf49c27ae0333719c2d7dda86ca7b0e (diff)
Make SFC installable as a python module
New directory structure: <root>/sfc <root>/sfc/lib/ <root>/sfc/tests <root>/sfc/tests/functest JIRA: SFC-60 After installing sfc, the imports would be: import sfc.tests.functest.x import sfc.lib.x Change-Id: Ib15172239aefdef65056d6598210a1b28a4b2eff Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'sfc/lib/results.py')
-rw-r--r--sfc/lib/results.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/sfc/lib/results.py b/sfc/lib/results.py
new file mode 100644
index 00000000..5fa9aa05
--- /dev/null
+++ b/sfc/lib/results.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2016 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+import functest.utils.functest_logger as ft_logger
+
+logger = ft_logger.Logger("sfc-results").getLogger()
+
+
+class Results(object):
+
+ def __init__(self, line_length):
+ self.line_length = line_length
+ self.test_result = "FAIL"
+ self.summary = ""
+ self.details = []
+ self.num_tests = 0
+ self.num_tests_failed = 0
+
+ def add_to_summary(self, num_cols, col1, col2=""):
+ if num_cols == 0:
+ self.summary += ("+%s+\n" % (col1 * (self.line_length - 2)))
+ elif num_cols == 1:
+ self.summary += ("| " + col1.ljust(self.line_length - 3) + "|\n")
+ elif num_cols == 2:
+ self.summary += ("| %s" % col1.ljust(7) + "| ")
+ self.summary += (col2.ljust(self.line_length - 12) + "|\n")
+ if col1 in ("FAIL", "PASS"):
+ self.details.append({col2: col1})
+ self.num_tests += 1
+ if col1 == "FAIL":
+ self.num_tests_failed += 1
+
+ def compile_summary(self):
+ success_message = "All the subtests have passed."
+ failure_message = "One or more subtests have failed."
+
+ self.add_to_summary(0, "=")
+ logger.info("\n%s" % self.summary)
+ if self.num_tests_failed == 0:
+ self.test_result = "PASS"
+ logger.info(success_message)
+ else:
+ logger.info(failure_message)
+
+ return {"status": self.test_result, "details": self.details}