summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Ke <lokyse@163.com>2018-03-27 02:25:20 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-27 02:25:20 +0000
commit4f845cea0e410bbac9d65651fdd71036841b688f (patch)
treebfcd0b30f1e33a394ca201486ed83de26af51723
parentb4eee071271ad4106bdbe486f58ae59ea46e2fc2 (diff)
parente5bc47a68acf51a4feab1337bc59ac3e36cdd7c1 (diff)
Merge "Add test_delete_dirs_failed"
-rw-r--r--multivimbroker/multivimbroker/tests/test_fileutil.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/multivimbroker/multivimbroker/tests/test_fileutil.py b/multivimbroker/multivimbroker/tests/test_fileutil.py
index 521c3b4..9abd23c 100644
--- a/multivimbroker/multivimbroker/tests/test_fileutil.py
+++ b/multivimbroker/multivimbroker/tests/test_fileutil.py
@@ -40,3 +40,12 @@ class TestFileutil(unittest.TestCase):
new_path = "/tmp/tests"
fileutil.delete_dirs(new_path)
mock_rmtree.assert_called_once_with(new_path)
+
+ @mock.patch.object(os.path, "exists")
+ @mock.patch("shutil.rmtree")
+ def test_delete_dirs_failed(self, mock_rmtree, mock_exists):
+ mock_exists.return_value = True
+ mock_rmtree.side_effect = [Exception("Fake exception")]
+ new_path = "/tmp/tests"
+ fileutil.delete_dirs(new_path)
+ mock_rmtree.assert_called_once_with(new_path)