From 3a1b40ff15b73ca05ab2565e7217f281dbadad9e Mon Sep 17 00:00:00 2001 From: Adriano Petrich Date: Wed, 25 Apr 2018 15:28:28 +0100 Subject: [PATCH] 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 --- mistral_tempest_tests/services/base.py | 14 +++++++++++++- .../tests/api/v2/test_executions.py | 8 ++++++-- mistral_tempest_tests/tests/api/v2/test_tasks.py | 2 +- mistral_tempest_tests/tests/base.py | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/mistral_tempest_tests/services/base.py b/mistral_tempest_tests/services/base.py index 5ee7d51..50030f2 100644 --- a/mistral_tempest_tests/services/base.py +++ b/mistral_tempest_tests/services/base.py @@ -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): diff --git a/mistral_tempest_tests/tests/api/v2/test_executions.py b/mistral_tempest_tests/tests/api/v2/test_executions.py index b577ff2..df50d7b 100644 --- a/mistral_tempest_tests/tests/api/v2/test_executions.py +++ b/mistral_tempest_tests/tests/api/v2/test_executions.py @@ -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) diff --git a/mistral_tempest_tests/tests/api/v2/test_tasks.py b/mistral_tempest_tests/tests/api/v2/test_tasks.py index 7527824..aa46bb1 100644 --- a/mistral_tempest_tests/tests/api/v2/test_tasks.py +++ b/mistral_tempest_tests/tests/api/v2/test_tasks.py @@ -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() diff --git a/mistral_tempest_tests/tests/base.py b/mistral_tempest_tests/tests/base.py index 9a75259..13116bc 100644 --- a/mistral_tempest_tests/tests/base.py +++ b/mistral_tempest_tests/tests/base.py @@ -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 = []