@@ -212,6 +212,28 @@ def test_wait_for_delete_error(self, mock_sleep):
212212 self .assertFalse (utils .wait_for_delete (manager , res_id ))
213213 self .assertFalse (mock_sleep .called )
214214
215+ @mock .patch .object (time , 'sleep' )
216+ def test_wait_for_delete_error_with_overrides (self , mock_sleep ):
217+ # Tests that we fail if the resource is my_status=failed
218+ resource = mock .MagicMock (my_status = 'FAILED' )
219+ mock_get = mock .Mock (return_value = resource )
220+ manager = mock .MagicMock (get = mock_get )
221+ res_id = str (uuid .uuid4 ())
222+ self .assertFalse (utils .wait_for_delete (manager , res_id ,
223+ status_field = 'my_status' ,
224+ error_status = ['failed' ]))
225+ self .assertFalse (mock_sleep .called )
226+
227+ @mock .patch .object (time , 'sleep' )
228+ def test_wait_for_delete_error_with_overrides_exception (self , mock_sleep ):
229+ # Tests that we succeed if the resource is specific exception
230+ mock_get = mock .Mock (side_effect = Exception )
231+ manager = mock .MagicMock (get = mock_get )
232+ res_id = str (uuid .uuid4 ())
233+ self .assertTrue (utils .wait_for_delete (manager , res_id ,
234+ exception_name = ['Exception' ]))
235+ self .assertFalse (mock_sleep .called )
236+
215237 def test_build_kwargs_dict_value_set (self ):
216238 self .assertEqual ({'arg_bla' : 'bla' },
217239 utils .build_kwargs_dict ('arg_bla' , 'bla' ))
0 commit comments