Add variablefile as possible robot.run() args
authorCédric Ollivier <cedric.ollivier@orange.com>
Wed, 7 Feb 2018 15:08:05 +0000 (16:08 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Wed, 7 Feb 2018 18:42:53 +0000 (19:42 +0100)
Change-Id: Ic80840957b4d9c3c4a1615696a2851f3f5bf7bf4
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/core/robotframework.py
functest/tests/unit/core/test_robotframework.py
functest/tests/unit/odl/test_odl.py

index 689d9d9..ccfa26b 100644 (file)
@@ -96,6 +96,7 @@ class RobotFramework(testcase.TestCase):
         try:
             suites = kwargs["suites"]
             variable = kwargs.get("variable", [])
+            variablefile = kwargs.get("variablefile", [])
         except KeyError:
             self.__logger.exception("Mandatory args were not passed")
             return self.EX_RUN_ERROR
@@ -109,8 +110,9 @@ class RobotFramework(testcase.TestCase):
             self.__logger.exception("Cannot create %s", self.res_dir)
             return self.EX_RUN_ERROR
         stream = StringIO()
-        robot.run(*suites, variable=variable, output=self.xml_file,
-                  log='NONE', report='NONE', stdout=stream)
+        robot.run(*suites, variable=variable, variablefile=variablefile,
+                  output=self.xml_file, log='NONE',
+                  report='NONE', stdout=stream)
         self.__logger.info("\n" + stream.getvalue())
         self.__logger.info("Results were successfully generated")
         try:
index 38e9039..28fd15f 100644 (file)
@@ -117,6 +117,7 @@ class RunTesting(unittest.TestCase):
 
     suites = ["foo"]
     variable = []
+    variablefile = []
 
     def setUp(self):
         self.test = robotframework.RobotFramework(
@@ -129,7 +130,9 @@ class RunTesting(unittest.TestCase):
     def _test_makedirs_exc(self, *args):
         with mock.patch.object(self.test, 'parse_results') as mock_method:
             self.assertEqual(
-                self.test.run(suites=self.suites, variable=self.variable),
+                self.test.run(
+                    suites=self.suites, variable=self.variable,
+                    variablefile=self.variablefile),
                 self.test.EX_RUN_ERROR)
             args[0].assert_not_called()
             mock_method.asser_not_called()
@@ -152,7 +155,8 @@ class RunTesting(unittest.TestCase):
                 self.test.EX_OK)
             args[0].assert_called_once_with(
                 *self.suites, log='NONE', output=self.test.xml_file,
-                report='NONE', stdout=mock.ANY, variable=self.variable)
+                report='NONE', stdout=mock.ANY, variable=self.variable,
+                variablefile=self.variablefile)
             mock_method.assert_called_once_with()
 
     @mock.patch('os.makedirs', side_effect=OSError(errno.EEXIST, ''))
@@ -168,10 +172,14 @@ class RunTesting(unittest.TestCase):
     @mock.patch('robot.run')
     def _test_parse_results(self, status, *args):
         self.assertEqual(
-            self.test.run(suites=self.suites, variable=self.variable), status)
+            self.test.run(
+                suites=self.suites, variable=self.variable,
+                variablefile=self.variablefile),
+            status)
         args[0].assert_called_once_with(
             *self.suites, log='NONE', output=self.test.xml_file,
-            report='NONE', stdout=mock.ANY, variable=self.variable)
+            report='NONE', stdout=mock.ANY, variable=self.variable,
+            variablefile=self.variablefile)
 
     def test_parse_results_exc(self):
         with mock.patch.object(self.test, 'parse_results',
index 1a3f795..b93ad31 100644 (file)
@@ -153,7 +153,7 @@ class ODLMainTesting(ODLTesting):
     def _test_run_suites(self, status, *args):
         kwargs = self._get_run_suites_kwargs()
         self.assertEqual(self.test.run_suites(**kwargs), status)
-        if len(args) > 0:
+        if args:
             args[0].assert_called_once_with(self.test.odl_variables_file)
         if len(args) > 1:
             variable = [
@@ -171,13 +171,11 @@ class ODLMainTesting(ODLTesting):
                 'PORT:{}'.format(self._odl_webport),
                 'RESTCONFPORT:{}'.format(self._odl_restconfport)]
             args[1].assert_called_once_with(
-                odl.ODLTests.basic_suite_dir,
-                odl.ODLTests.neutron_suite_dir,
+                odl.ODLTests.basic_suite_dir, odl.ODLTests.neutron_suite_dir,
                 log='NONE',
                 output=os.path.join(self.test.res_dir, 'output.xml'),
-                report='NONE',
-                stdout=mock.ANY,
-                variable=variable)
+                report='NONE', stdout=mock.ANY, variable=variable,
+                variablefile=[])
 
     def _test_no_keyword(self, key):
         kwargs = self._get_run_suites_kwargs(key)