Consider criteria as exit condition in odl test
authorMorgan Richomme <morgan.richomme@orange.com>
Thu, 24 Nov 2016 14:58:12 +0000 (15:58 +0100)
committerMorgan Richomme <morgan.richomme@orange.com>
Thu, 24 Nov 2016 14:58:12 +0000 (15:58 +0100)
JIRA: FUNCTEST-621

Change-Id: Ic9dd73861d84e3dbfb3e6611ffc9e5e2c09fcaed
Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
functest/opnfv_tests/Controllers/ODL/OpenDaylightTesting.py
functest/tests/unit/odl/test_odl.py

index 8c003ab..b755c40 100755 (executable)
@@ -83,6 +83,7 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
         self.details = {}
         self.details['description'] = result.suite.name
         self.details['tests'] = visitor.get_data()
+        return self.criteria
 
     def main(self, **kwargs):
         dirs = [self.basic_suite_dir, self.neutron_suite_dir]
@@ -120,8 +121,10 @@ class ODLTestCases(TestCasesBase.TestCasesBase):
                 self.logger.info("\n" + stdout.read())
             self.logger.info("ODL results were successfully generated")
             try:
-                self.parse_results()
+                test_res = self.parse_results()
                 self.logger.info("ODL results were successfully parsed")
+                if test_res is not "PASS":
+                    return self.EX_RUN_ERROR
             except RobotError as e:
                 self.logger.error("Run tests before publishing: %s" %
                                   e.message)
index 3f33dc8..a62bf39 100644 (file)
@@ -201,7 +201,8 @@ class ODLTestCasesTesting(unittest.TestCase):
     def test_main(self, *args):
         with mock.patch.object(self.test, 'set_robotframework_vars',
                                return_value=True), \
-                mock.patch.object(self.test, 'parse_results'):
+                mock.patch.object(self.test, 'parse_results',
+                                  return_value="PASS"):
             self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args)
 
     @mock.patch('os.remove')
@@ -210,7 +211,8 @@ class ODLTestCasesTesting(unittest.TestCase):
     def test_main_makedirs_oserror17(self, *args):
         with mock.patch.object(self.test, 'set_robotframework_vars',
                                return_value=True), \
-                mock.patch.object(self.test, 'parse_results'):
+                mock.patch.object(self.test, 'parse_results',
+                                  return_value="PASS"):
             self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args)
 
     @mock.patch('os.remove')
@@ -219,7 +221,8 @@ class ODLTestCasesTesting(unittest.TestCase):
     def test_main_testcases_in_failure(self, *args):
         with mock.patch.object(self.test, 'set_robotframework_vars',
                                return_value=True), \
-                mock.patch.object(self.test, 'parse_results'):
+                mock.patch.object(self.test, 'parse_results',
+                                  return_value="PASS"):
             self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args)
 
     @mock.patch('os.remove', side_effect=OSError)
@@ -228,7 +231,8 @@ class ODLTestCasesTesting(unittest.TestCase):
     def test_main_remove_oserror(self, *args):
         with mock.patch.object(self.test, 'set_robotframework_vars',
                                return_value=True), \
-                mock.patch.object(self.test, 'parse_results'):
+                mock.patch.object(self.test, 'parse_results',
+                                  return_value="PASS"):
             self._test_main(TestCasesBase.TestCasesBase.EX_OK, *args)
 
     def _test_run_missing_env_var(self, var):