Remove unexpected Resource.update overrides

These should actually be Resource.commit.

Change-Id: I59374b7cdd0dbba8de0dab28e46f9b08f0f1aa59
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-08-29 14:38:48 +01:00
parent c96d57f768
commit e614f8ea76
5 changed files with 31 additions and 32 deletions
openstack
orchestration/v1
tests/unit/orchestration/v1
workflow/v2

@ -167,7 +167,7 @@ class Proxy(proxy.Proxy):
"""
return self._get(_stack.Stack, stack, resolve_outputs=resolve_outputs)
def update_stack(self, stack, preview=False, **attrs):
def update_stack(self, stack, *, preview=False, **attrs):
"""Update a stack
:param stack: The value can be the ID of a stack or a
@ -181,7 +181,7 @@ class Proxy(proxy.Proxy):
when no resource can be found.
"""
res = self._get_resource(_stack.Stack, stack, **attrs)
return res.update(self, preview)
return res.commit(self, preview)
def delete_stack(self, stack, ignore_missing=True):
"""Delete a stack

@ -117,14 +117,18 @@ class Stack(resource.Resource):
# heat doesn't accept resource_key in its request.
return super().create(session, prepend_key=False, base_path=base_path)
def commit(self, session, base_path=None):
# This overrides the default behavior of resource creation because
# heat doesn't accept resource_key in its request.
return super().commit(
session, prepend_key=False, has_body=False, base_path=None
)
def update(self, session, preview=False):
def commit(
self,
session,
prepend_key=True,
has_body=True,
retry_on_conflict=None,
base_path=None,
*,
microversion=None,
preview=False,
**kwargs,
):
# This overrides the default behavior of resource update because
# we need to use other endpoint for update preview.
base_path = None

@ -96,7 +96,7 @@ class TestOrchestrationStack(TestOrchestrationProxy):
def test_update_stack(self):
self._verify(
'openstack.orchestration.v1.stack.Stack.update',
'openstack.orchestration.v1.stack.Stack.commit',
self.proxy.update_stack,
expected_result='result',
method_args=['stack'],
@ -106,7 +106,7 @@ class TestOrchestrationStack(TestOrchestrationProxy):
def test_update_stack_preview(self):
self._verify(
'openstack.orchestration.v1.stack.Stack.update',
'openstack.orchestration.v1.stack.Stack.commit',
self.proxy.update_stack,
expected_result='result',
method_args=['stack'],

@ -188,18 +188,6 @@ class TestStack(base.TestCase):
)
self.assertEqual(mock_create.return_value, res)
@mock.patch.object(resource.Resource, 'commit')
def test_commit(self, mock_commit):
sess = mock.Mock()
sot = stack.Stack()
res = sot.commit(sess)
mock_commit.assert_called_once_with(
sess, prepend_key=False, has_body=False, base_path=None
)
self.assertEqual(mock_commit.return_value, res)
def test_check(self):
sess = mock.Mock()
sot = stack.Stack(**FAKE)
@ -287,7 +275,7 @@ class TestStack(base.TestCase):
f'stacks/{FAKE_NAME}/{FAKE_ID}/export',
)
def test_update(self):
def test_commit(self):
sess = mock.Mock()
sess.default_microversion = None
@ -299,7 +287,7 @@ class TestStack(base.TestCase):
sot = stack.Stack(**FAKE)
body = sot._body.dirty.copy()
sot.update(sess)
sot.commit(sess)
sess.put.assert_called_with(
f'/stacks/{FAKE_NAME}/{FAKE_ID}',
@ -308,7 +296,7 @@ class TestStack(base.TestCase):
json=body,
)
def test_update_preview(self):
def test_commit_preview(self):
sess = mock.Mock()
sess.default_microversion = None
@ -320,7 +308,7 @@ class TestStack(base.TestCase):
sot = stack.Stack(**FAKE)
body = sot._body.dirty.copy()
ret = sot.update(sess, preview=True)
ret = sot.commit(sess, preview=True)
sess.put.assert_called_with(
f'stacks/{FAKE_NAME}/{FAKE_ID}/preview',

@ -72,13 +72,20 @@ class Workflow(resource.Resource):
self._translate_response(response, has_body=False)
return self
def update(self, session, prepend_key=True, base_path=None):
def commit(
self,
session,
prepend_key=True,
has_body=True,
retry_on_conflict=None,
base_path=None,
*,
microversion=None,
**kwargs,
):
kwargs = self._request_kwargs(
prepend_key=prepend_key, base_path=base_path
)
response = session.put(**kwargs)
self._translate_response(response, has_body=False)
return self
def commit(self, *args, **kwargs):
return self.update(*args, **kwargs)