Merge "Fix heat stack _action function to handle exception"
This commit is contained in:
commit
6b6ac851a2
@ -165,8 +165,9 @@ class Stack(resource.Resource):
|
||||
def _action(self, session, body):
|
||||
"""Perform stack actions"""
|
||||
url = utils.urljoin(self.base_path, self._get_id(self), 'actions')
|
||||
resp = session.post(url, json=body)
|
||||
return resp.json()
|
||||
resp = session.post(url, json=body, microversion=self.microversion)
|
||||
exceptions.raise_from_response(resp)
|
||||
return resp
|
||||
|
||||
def check(self, session):
|
||||
return self._action(session, {'check': ''})
|
||||
|
@ -206,12 +206,19 @@ class TestStack(base.TestCase):
|
||||
sess = mock.Mock()
|
||||
sot = stack.Stack(**FAKE)
|
||||
sot._action = mock.Mock()
|
||||
sot._action.side_effect = [
|
||||
test_resource.FakeResponse(None, 200, None),
|
||||
exceptions.BadRequestException(message='oops'),
|
||||
exceptions.NotFoundException(message='oops'),
|
||||
]
|
||||
body = {'check': ''}
|
||||
|
||||
sot.check(sess)
|
||||
|
||||
sot._action.assert_called_with(sess, body)
|
||||
|
||||
self.assertRaises(exceptions.BadRequestException, sot.check, sess)
|
||||
self.assertRaises(exceptions.NotFoundException, sot.check, sess)
|
||||
|
||||
def test_fetch(self):
|
||||
sess = mock.Mock()
|
||||
sess.default_microversion = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user