Merge "Update tearDown methods in API integration tests"

This commit is contained in:
Jenkins 2014-10-02 16:55:49 +00:00 committed by Gerrit Code Review
commit 52eaf4973e
3 changed files with 52 additions and 16 deletions

View File

@ -50,6 +50,8 @@ class WorkbookTestsV1(base.TestCase):
self.assertEqual('test', body['workbooks'][0]['name'])
self.client.delete_obj('workbooks', 'test')
self.client.workbooks.remove('test')
_, body = self.client.get_list_obj('workbooks')
self.assertEqual([], body['workbooks'])
@ -107,6 +109,7 @@ class WorkbookTestsV1(base.TestCase):
'test')
self.client.delete_obj('workbooks', 'test')
self.client.workbooks.remove('test')
_, body = self.client.get_list_obj('workbooks')
self.assertEqual([], body['workbooks'])
@ -127,9 +130,9 @@ class ExecutionTestsV1(base.TestCase):
def tearDown(self):
super(ExecutionTestsV1, self).tearDown()
_, executions = self.client.get_list_obj('executions')
for ex in executions['executions']:
self.client.delete_obj('executions', '{0}'.format(ex['id']))
for ex in self.client.executions:
self.client.delete_obj('executions', ex)
self.client.executions.remove(ex)
@test.attr(type='positive')
def test_create_execution(self):

View File

@ -22,15 +22,22 @@ class WorkbookTestsV2(test_mistral_basic.WorkbookTestsV1):
_version = 2
def tearDown(self):
for wf in self.client.workflows:
self.client.delete_obj('workflows', wf)
self.client.workflows.remove(wf)
super(WorkbookTestsV2, self).tearDown()
class WorkflowTestsV2(base.TestCase):
_version = 2
def tearDown(self):
_, wfs = self.client.get_list_obj('workflows')
for wf in wfs['workflows']:
self.client.delete_obj('workflows', wf['name'])
for wf in self.client.workflows:
self.client.delete_obj('workflows', wf)
self.client.workflows.remove(wf)
super(WorkflowTestsV2, self).tearDown()
@ -56,6 +63,8 @@ class WorkflowTestsV2(base.TestCase):
self.assertIn('wf', names)
self.client.delete_obj('workflows', 'wf')
self.client.workflows.remove('wf')
_, body = self.client.get_list_obj('workflows')
names = [body['workflows'][i]['name']
@ -96,3 +105,10 @@ class ExecutionTestsV2(test_mistral_basic.ExecutionTestsV1):
self.entity_type = 'workflow_name'
self.entity_name = 'test.test'
def tearDown(self):
for wf in self.client.workflows:
self.client.delete_obj('workflows', wf)
self.client.workflows.remove(wf)
super(ExecutionTestsV2, self).tearDown()

View File

@ -69,6 +69,10 @@ class MistralClientBase(rest_client.RestClient):
self.endpoint_url = 'publicURL'
self.workbooks = []
self.executions = []
self.workflows = []
def get_list_obj(self, name):
resp, body = self.get(name)
return resp, json.loads(body)
@ -88,6 +92,9 @@ class MistralClientV1(MistralClientBase):
def create_workbook(self, name):
post_body = '{"name": "%s"}' % name
resp, body = self.post('workbooks', post_body)
self.workbooks.append(name)
return resp, json.loads(body)
def update_workbook(self, name):
@ -122,6 +129,8 @@ class MistralClientV1(MistralClientBase):
rest, body = self.post('workbooks/{name}/executions'.format(
name=workbook_name), json.dumps(body))
self.executions.append(json.loads(body)['id'])
return rest, json.loads(body)
def update_execution(self, execution_id, put_body):
@ -209,6 +218,11 @@ class MistralClientV2(MistralClientBase):
post_body = {"definition": "%s" % text}
resp, body = self.post('workbooks', json.dumps(post_body))
self.workbooks.append(json.loads(body)['name'])
_, wfs = self.get('workflows')
self.workflows.append(json.loads(wfs)['workflows'][0]['name'])
return resp, json.loads(body)
def update_workbook(self, name):
@ -236,6 +250,8 @@ class MistralClientV2(MistralClientBase):
resp, body = self.post('workflows',
json.dumps(post_body))
self.workflows.append(json.loads(body)['workflows'][0]['name'])
return resp, json.loads(body)
def update_workflow(self):
@ -256,6 +272,8 @@ class MistralClientV2(MistralClientBase):
body = post_body
rest, body = self.post('executions', body)
self.executions.append(json.loads(body)['id'])
return rest, json.loads(body)
def update_execution(self, execution_id, put_body):
@ -313,9 +331,9 @@ class TestCase(tempest.test.BaseTestCase):
def tearDown(self):
super(TestCase, self).tearDown()
_, items = self.client.get_list_obj('workbooks')
for i in items['workbooks']:
self.client.delete_obj('workbooks', i['name'])
for wb in self.client.workbooks:
self.client.delete_obj('workbooks', wb)
self.client.workbooks.remove(wb)
class TestCaseAdvanced(TestCase):
@ -335,13 +353,12 @@ class TestCaseAdvanced(TestCase):
self.client.create_workbook(self.workbook_name)
def tearDown(self):
_, items = self.client.get_list_obj('workbooks')
for i in items['workbooks']:
self.client.delete_obj('workbooks', i['name'])
for wb in self.client.workbooks:
self.client.delete_obj('workbooks', wb)
self.client.workbooks.remove(wb)
_, executions = self.client.get_list_obj('executions')
for ex in executions['executions']:
self.client.delete_obj('executions', '{0}'.format(ex['id']))
for ex in self.client.executions:
self.client.delete_obj('executions', ex)
self.client.executions.remove(ex)
super(TestCaseAdvanced, self).tearDown()