From 3de95504a9a329cefcdec2ea9508709118bbf94e Mon Sep 17 00:00:00 2001 From: Edward MacGillivray Date: Fri, 15 Sep 2017 16:45:41 -0700 Subject: Ensure that at least one handler is available https://jira.opnfv.org/browse/YARDSTICK-773?filter=-3 Remove dependency of yardstick on utils methods Change-Id: Iadf502364a7f08c279a8f0d17d7e45e8047f4066 Signed-off-by: Edward MacGillivray --- tests/unit/common/test_utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py index 923ec4aaa..42b75d1f0 100644 --- a/tests/unit/common/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -17,6 +17,7 @@ import unittest from copy import deepcopy from itertools import product, chain +import errno import mock from six.moves import configparser @@ -780,6 +781,21 @@ class RemoveFileTestCase(unittest.TestCase): class TestUtils(unittest.TestCase): + @mock.patch('yardstick.common.utils.os.makedirs') + def test_makedirs(self, *_): + self.assertIsNone(utils.makedirs('a/b/c/d')) + + @mock.patch('yardstick.common.utils.os.makedirs') + def test_makedirs_exists(self, mock_os_makedirs): + mock_os_makedirs.side_effect = OSError(errno.EEXIST, 'exists') + self.assertIsNone(utils.makedirs('a/b/c/d')) + + @mock.patch('yardstick.common.utils.os.makedirs') + def test_makedirs_busy(self, mock_os_makedirs): + mock_os_makedirs.side_effect = OSError(errno.EBUSY, 'busy') + with self.assertRaises(OSError): + utils.makedirs('a/b/c/d') + @mock.patch('yardstick.common.utils.jsonify') def test_result_handler(self, mock_jsonify): mock_jsonify.return_value = 432 -- cgit 1.2.3-korg