summaryrefslogtreecommitdiffstats
path: root/tests/functest/odl-sfc/results.py
diff options
context:
space:
mode:
authorVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-06 12:37:23 +0530
committerVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-06 12:53:52 +0530
commita2bb382c7fdbdb32961f9e2fdbbae91fbd4ae5bc (patch)
tree1897eb6a191912eb1119a66888ac50cf371bcafb /tests/functest/odl-sfc/results.py
parent3353aa64745f051e5e5cacdd964837476acf6f6c (diff)
odl-sfc refactor:Results class to tests
- JIRA:SFC-54 - Add result.py for test results - This doesn't use results class and configs effectively - run_tests.py patch will use these effectively (avoided for clarity in this patch) Change-Id: I5bef776a01ca9789a22b5628aa3501d9dbc46a26 Signed-off-by: Vijayendra Radhakrishna <vradhakrishna@mvista.com>
Diffstat (limited to 'tests/functest/odl-sfc/results.py')
-rw-r--r--tests/functest/odl-sfc/results.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/functest/odl-sfc/results.py b/tests/functest/odl-sfc/results.py
new file mode 100644
index 00000000..69e5523b
--- /dev/null
+++ b/tests/functest/odl-sfc/results.py
@@ -0,0 +1,53 @@
+#!/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)
+ status = "FAILED"
+ if self.test_result == "PASS":
+ status = "PASS"
+ logger.info(success_message)
+ else:
+ logger.info(failure_message)
+
+ return {"status": status, "details": self.details}