diff options
| author | Mark Vanderwiel <vanderwl@us.ibm.com> | 2016-01-28 10:52:45 -0600 |
|---|---|---|
| committer | Mark Vanderwiel <vanderwl@us.ibm.com> | 2016-01-28 10:52:45 -0600 |
| commit | 5903ffff8a56481e124aa4fe8144c16348f6f8b9 (patch) | |
| tree | b9455bb9f4bd06bf4e4465472a303954d44a326f /openstackclient/tests/common/test_utils.py | |
| parent | 636b4de6df77923424f7cac62322b546d65a5269 (diff) | |
| download | python-openstackclient-5903ffff8a56481e124aa4fe8144c16348f6f8b9.tar.gz | |
Allow wait_for_delete to work for all clients
Allow the exception and error status
strings to be passed in such that other plugins can
make use of this function.
There is a comment in find_resource:
The exception to catch here is dependent on which
client library the manager passed in belongs to.
Eventually this should be pulled from a common set
of client exceptions.
Since I think that is a long ways off, this change will
work now and also work when a common exception is defined
and used.
Change-Id: Iab56cd1166028caed4f1e657e0b1ee81af3f48d8
Diffstat (limited to 'openstackclient/tests/common/test_utils.py')
| -rw-r--r-- | openstackclient/tests/common/test_utils.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/openstackclient/tests/common/test_utils.py b/openstackclient/tests/common/test_utils.py index 064ad417..9c02df31 100644 --- a/openstackclient/tests/common/test_utils.py +++ b/openstackclient/tests/common/test_utils.py @@ -212,6 +212,28 @@ class TestUtils(test_utils.TestCase): self.assertFalse(utils.wait_for_delete(manager, res_id)) self.assertFalse(mock_sleep.called) + @mock.patch.object(time, 'sleep') + def test_wait_for_delete_error_with_overrides(self, mock_sleep): + # Tests that we fail if the resource is my_status=failed + resource = mock.MagicMock(my_status='FAILED') + mock_get = mock.Mock(return_value=resource) + manager = mock.MagicMock(get=mock_get) + res_id = str(uuid.uuid4()) + self.assertFalse(utils.wait_for_delete(manager, res_id, + status_field='my_status', + error_status=['failed'])) + self.assertFalse(mock_sleep.called) + + @mock.patch.object(time, 'sleep') + def test_wait_for_delete_error_with_overrides_exception(self, mock_sleep): + # Tests that we succeed if the resource is specific exception + mock_get = mock.Mock(side_effect=Exception) + manager = mock.MagicMock(get=mock_get) + res_id = str(uuid.uuid4()) + self.assertTrue(utils.wait_for_delete(manager, res_id, + exception_name=['Exception'])) + self.assertFalse(mock_sleep.called) + def test_build_kwargs_dict_value_set(self): self.assertEqual({'arg_bla': 'bla'}, utils.build_kwargs_dict('arg_bla', 'bla')) |
