Adds the force parameter to delete executions
This is an intermediary step so the tests can work with or without the force parameter. Once the force parameter has landed in mistral I will remove the try except from this implementation. Change-Id: Id935265fcbe0a3072ba2d693edf54b892173fbdf
This commit is contained in:
parent
530bee8d11
commit
3a1b40ff15
|
@ -79,7 +79,19 @@ class MistralClientBase(rest_client.RestClient):
|
|||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def delete_obj(self, obj, name):
|
||||
def delete_obj(self, obj, name, force=None):
|
||||
if force:
|
||||
# TODO(apetrich) This try except is a partial implementation
|
||||
# to be removed once force deletion lands in mistral
|
||||
try:
|
||||
return self.delete('{obj}/{name}?force={force}'.format(
|
||||
obj=obj,
|
||||
name=name,
|
||||
force=bool(force))
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return self.delete('{obj}/{name}'.format(obj=obj, name=name))
|
||||
|
||||
def get_object(self, obj, id):
|
||||
|
|
|
@ -44,7 +44,7 @@ class ExecutionTestsV2(base.TestCase):
|
|||
self.client.workflows = []
|
||||
|
||||
for ex in self.client.executions:
|
||||
self.client.delete_obj('executions', ex)
|
||||
self.client.delete_obj('executions', ex, force=True)
|
||||
self.client.executions = []
|
||||
|
||||
super(ExecutionTestsV2, self).tearDown()
|
||||
|
@ -317,7 +317,11 @@ class ExecutionTestsV2(base.TestCase):
|
|||
def test_delete_execution_by_admin(self):
|
||||
_, body = self.client.create_execution(self.direct_wf_id)
|
||||
exec_id = body['id']
|
||||
resp, _ = self.admin_client.delete_obj('executions', exec_id)
|
||||
resp, _ = self.admin_client.delete_obj(
|
||||
'executions',
|
||||
exec_id,
|
||||
force=True
|
||||
)
|
||||
|
||||
self.assertEqual(204, resp.status)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class TasksTestsV2(base.TestCase):
|
|||
self.client.workflows = []
|
||||
|
||||
for wf in self.client.executions:
|
||||
self.client.delete_obj('executions', wf)
|
||||
self.client.delete_obj('executions', wf, force=True)
|
||||
self.client.executions = []
|
||||
|
||||
super(TasksTestsV2, self).tearDown()
|
||||
|
|
|
@ -83,7 +83,7 @@ class TestCaseAdvanced(TestCase):
|
|||
self.client.workbooks = []
|
||||
|
||||
for ex in self.client.executions:
|
||||
self.client.delete_obj('executions', ex)
|
||||
self.client.delete_obj('executions', ex, force=True)
|
||||
|
||||
self.client.executions = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue