summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-06-17 11:41:08 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-06-18 19:28:04 +0200
commit594a3f389add82469ef66462cdbd30347945f6ee (patch)
treefe26d14ca55324345abc4a5ecaf3b4047b3e32e9
parente13e87d9d064c2427208104d3dacc9b8aee95b6e (diff)
Mock os.makedirs() in test_odl.py
os.makedirs() is called before calling robot.run. Change-Id: Id651428343510683cd616d8101d22a73ccbf3dad Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 383ed86699816f633f007c515338d0fa022bf4fc)
-rw-r--r--functest/opnfv_tests/sdn/odl/odl.py5
-rw-r--r--functest/tests/unit/odl/test_odl.py5
2 files changed, 7 insertions, 3 deletions
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index a975a081f..9ba2931f0 100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -191,9 +191,8 @@ class ODLTests(robotframework.RobotFramework):
kwargs['odlrestconfport'] = '8087'
assert kwargs['odlip']
except KeyError as ex:
- self.__logger.error("Cannot run ODL testcases. "
- "Please check env var: "
- "%s", str(ex))
+ self.__logger.error(
+ "Cannot run ODL testcases. Please check env var: %s", str(ex))
return self.EX_RUN_ERROR
except Exception: # pylint: disable=broad-except
self.__logger.exception("Cannot run ODL testcases.")
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 62296c01c..5d147a96b 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -225,6 +225,7 @@ class ODLMainTesting(ODLTesting):
self._odl_username, self._odl_password)
args[0].assert_called_once_with(self.test.odl_variables_file)
+ @mock.patch('os.makedirs')
@mock.patch('robot.run', side_effect=RobotError)
@mock.patch('os.path.isfile', return_value=True)
def test_run_ko(self, *args):
@@ -233,6 +234,7 @@ class ODLMainTesting(ODLTesting):
self.assertRaises(RobotError):
self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
+ @mock.patch('os.makedirs')
@mock.patch('robot.run')
@mock.patch('os.path.isfile', return_value=True)
def test_parse_results_ko(self, *args):
@@ -242,6 +244,7 @@ class ODLMainTesting(ODLTesting):
side_effect=RobotError):
self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
+ @mock.patch('os.makedirs')
@mock.patch('robot.run')
@mock.patch('os.path.isfile', return_value=True)
def test_ok(self, *args):
@@ -250,6 +253,7 @@ class ODLMainTesting(ODLTesting):
mock.patch.object(self.test, 'parse_results'):
self._test_run_suites(testcase.TestCase.EX_OK, *args)
+ @mock.patch('os.makedirs')
@mock.patch('robot.run')
@mock.patch('os.path.isfile', return_value=False)
def test_ok_no_creds(self, *args):
@@ -259,6 +263,7 @@ class ODLMainTesting(ODLTesting):
self._test_run_suites(testcase.TestCase.EX_OK, *args)
mock_method.assert_not_called()
+ @mock.patch('os.makedirs')
@mock.patch('robot.run', return_value=1)
@mock.patch('os.path.isfile', return_value=True)
def test_testcases_in_failure(self, *args):