diff options
author | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-25 22:12:46 -0700 |
---|---|---|
committer | Ethan Lynn <ethanlynnl@vmware.com> | 2018-03-25 22:13:17 -0700 |
commit | e5bc47a68acf51a4feab1337bc59ac3e36cdd7c1 (patch) | |
tree | 1b53ae0e51c43113bcabbf7a448da0048397bb67 | |
parent | dcdca06c97e6b3c9b603b1e002384fb5122cf8ec (diff) |
Add test_delete_dirs_failed
Add test_delete_dirs_failed for fileutil.py
Change-Id: I1fda3bfacd85bb631f9687fa4ad0f1dcec896dc1
Issue-ID: MULTICLOUD-198
Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
-rw-r--r-- | multivimbroker/multivimbroker/tests/test_fileutil.py | 9 |
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) |