Merge "Add ut for nova returns HTTP 207 with all event code 400"
This commit is contained in:
commit
d27258edaa
|
@ -68,7 +68,7 @@ class NovaAPITest(base.TestCase):
|
|||
'yet associated with a host.')
|
||||
self.mock_log_info.assert_called_once_with(msg, self.instance_uuid)
|
||||
|
||||
def test_send_events_422_exception(self):
|
||||
def test_send_events_with_event_code_422_exception(self):
|
||||
# If Nova returns HTTP 207 with event code 422 for some events,
|
||||
# but not all, raise an exception. This is not expected to
|
||||
# happen with current code.
|
||||
|
@ -83,8 +83,8 @@ class NovaAPITest(base.TestCase):
|
|||
self.assertRaises(exception.InvalidAPIResponse,
|
||||
nova._send_events, self.events)
|
||||
|
||||
def test_send_events_non_422_exception(self):
|
||||
# If Nova returns HTTP 207 with event code other than 422,
|
||||
def test_send_events_with_event_code_400_exception(self):
|
||||
# If Nova returns HTTP 207 with event code 400 for some events,
|
||||
# raise an exception.
|
||||
resp_events = copy.deepcopy(self.events)
|
||||
resp_events[0].update({'status': 'failed', 'code': 400})
|
||||
|
@ -97,6 +97,21 @@ class NovaAPITest(base.TestCase):
|
|||
self.assertRaises(exception.InvalidAPIResponse,
|
||||
nova._send_events, self.events)
|
||||
|
||||
def test_send_events_with_all_event_code_400_exception(self):
|
||||
# If Nova returns HTTP 207 with event code 400 for all events,
|
||||
# raise an exception.
|
||||
resp_events = copy.deepcopy(self.events)
|
||||
for ev in resp_events:
|
||||
ev.update({'status': 'failed', 'code': 400})
|
||||
nova_resp = {'events': resp_events}
|
||||
mock_ret = mock.Mock(status_code=207)
|
||||
mock_ret.json.return_value = nova_resp
|
||||
self.mock_sdk.post.return_value = mock_ret
|
||||
|
||||
nova = nova_client.NovaAPI()
|
||||
self.assertRaises(exception.InvalidAPIResponse,
|
||||
nova._send_events, self.events)
|
||||
|
||||
def test_send_events_failure(self):
|
||||
# Nova is expected to return 200/207 but this is future-proofing.
|
||||
mock_ret = mock.Mock(status_code=400)
|
||||
|
|
Loading…
Reference in New Issue