Merge "support None as expected status in wait_for_status"
This commit is contained in:
commit
4e6d05c23f
openstack
@ -2305,7 +2305,7 @@ def wait_for_status(
|
||||
"""
|
||||
|
||||
current_status = getattr(resource, attribute)
|
||||
if _normalize_status(current_status) == status.lower():
|
||||
if _normalize_status(current_status) == _normalize_status(status):
|
||||
return resource
|
||||
|
||||
if failures is None:
|
||||
@ -2331,7 +2331,7 @@ def wait_for_status(
|
||||
|
||||
new_status = getattr(resource, attribute)
|
||||
normalized_status = _normalize_status(new_status)
|
||||
if normalized_status == status.lower():
|
||||
if normalized_status == _normalize_status(status):
|
||||
return resource
|
||||
elif normalized_status in failures:
|
||||
raise exceptions.ResourceFailure(
|
||||
|
@ -3155,6 +3155,18 @@ class TestWaitForStatus(base.TestCase):
|
||||
|
||||
self.assertEqual(result, resources[-1])
|
||||
|
||||
def test_status_match_none(self):
|
||||
status = None
|
||||
|
||||
# apparently, None can be expected status in some cases
|
||||
resources = self._resources_from_statuses(
|
||||
"first", "other", "another", "another", status)
|
||||
|
||||
result = resource.wait_for_status(
|
||||
mock.Mock(), resources[0], status, None, 1, 5)
|
||||
|
||||
self.assertEqual(result, resources[-1])
|
||||
|
||||
def test_status_match_different_attribute(self):
|
||||
status = "loling"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user