Manage criteria in TestCase
[functest.git] / functest / core / feature.py
index 00c7ec7..d65f5a3 100644 (file)
@@ -25,7 +25,7 @@ __author__ = ("Serena Feng <feng.xiaowei@zte.com.cn>, "
 
 
 class Feature(base.TestCase):
-    """Parent class of Functest Feature."""
+    """Base model for single feature."""
 
     def __init__(self, **kwargs):
         super(Feature, self).__init__(**kwargs)
@@ -34,11 +34,13 @@ class Feature(base.TestCase):
         self.logger = ft_logger.Logger(self.project_name).getLogger()
 
     def execute(self, **kwargs):
-        """Execute Feature.
+        """Execute the Python method.
 
         The subclasses must override the default implementation which
-        is false on purpose. The only prerequisite is to return 0 if
-        success or anything else if failure.
+        is false on purpose.
+
+        The new implementation must return 0 if success or anything
+        else if failure.
 
         Args:
             kwargs: Arbitrary keyword arguments.
@@ -50,14 +52,14 @@ class Feature(base.TestCase):
         return -1
 
     def run(self, **kwargs):
-        """Run Feature.
+        """Run the feature.
 
         It allows executing any Python method by calling execute().
 
         It sets the following attributes required to push the results
         to DB:
 
-            * criteria,
+            * result,
             * start_time,
             * stop_time.
 
@@ -72,15 +74,15 @@ class Feature(base.TestCase):
         """
         self.start_time = time.time()
         exit_code = base.TestCase.EX_RUN_ERROR
-        self.criteria = "FAIL"
+        self.result = 0
         try:
             if self.execute(**kwargs) == 0:
                 exit_code = base.TestCase.EX_OK
-                self.criteria = 'PASS'
+                self.result = 100
             ft_utils.logger_test_results(
                 self.project_name, self.case_name,
-                self.criteria, self.details)
-            self.logger.info("%s %s", self.project_name, self.criteria)
+                self.result, self.details)
+            self.logger.info("%s %s", self.project_name, self.result)
         except Exception:  # pylint: disable=broad-except
             self.logger.exception("%s FAILED", self.project_name)
         self.logger.info("Test result is stored in '%s'", self.result_file)