diff options
Diffstat (limited to 'oslo_concurrency/tests/unit/test_lockutils.py')
-rw-r--r-- | oslo_concurrency/tests/unit/test_lockutils.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py index 1bd74a2..2aea215 100644 --- a/oslo_concurrency/tests/unit/test_lockutils.py +++ b/oslo_concurrency/tests/unit/test_lockutils.py @@ -13,6 +13,7 @@ # under the License. import collections +import errno import multiprocessing import os import signal @@ -327,8 +328,8 @@ class LockTestCase(test_base.BaseTestCase): remove_mock.assert_called_once_with(path_mock.return_value) log_mock.assert_not_called() - @mock.patch('logging.Logger.info') - @mock.patch('os.remove', side_effect=OSError) + @mock.patch('logging.Logger.warning') + @mock.patch('os.remove', side_effect=OSError(errno.ENOENT, None)) @mock.patch('oslo_concurrency.lockutils._get_lock_path') def test_remove_lock_external_file_doesnt_exists(self, path_mock, remove_mock, log_mock): @@ -339,6 +340,20 @@ class LockTestCase(test_base.BaseTestCase): mock.sentinel.prefix, mock.sentinel.lock_path) remove_mock.assert_called_once_with(path_mock.return_value) + log_mock.assert_not_called() + + @mock.patch('logging.Logger.warning') + @mock.patch('os.remove', side_effect=OSError(errno.EPERM, None)) + @mock.patch('oslo_concurrency.lockutils._get_lock_path') + def test_remove_lock_external_file_permission_error( + self, path_mock, remove_mock, log_mock): + lockutils.remove_external_lock_file(mock.sentinel.name, + mock.sentinel.prefix, + mock.sentinel.lock_path) + path_mock.assert_called_once_with(mock.sentinel.name, + mock.sentinel.prefix, + mock.sentinel.lock_path) + remove_mock.assert_called_once_with(path_mock.return_value) log_mock.assert_called() def test_no_slash_in_b64(self): |