Merge "Fix API tests for v2 version"
This commit is contained in:
commit
50e28ed5ab
@ -68,7 +68,7 @@ class WorkbookTestsV1(base.TestCase):
|
||||
resp, body = self.client.update_workbook('test')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual('testupdated', body['name'])
|
||||
self.assertEqual('test', body['name'])
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_get_workbook_definition(self):
|
||||
|
@ -43,10 +43,10 @@ class WorkflowTestsV2(base.TestCase):
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_create_and_delete_workflow(self):
|
||||
resp, body = self.client.create_workflow('wf')
|
||||
resp, body = self.client.create_workflow()
|
||||
|
||||
self.assertEqual(201, resp.status)
|
||||
self.assertEqual('wf', body['name'])
|
||||
self.assertEqual('wf', body['workflows'][0]['name'])
|
||||
|
||||
resp, body = self.client.get_list_obj('workflows')
|
||||
|
||||
@ -64,7 +64,7 @@ class WorkflowTestsV2(base.TestCase):
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_get_workflow(self):
|
||||
self.client.create_workflow('wf')
|
||||
self.client.create_workflow()
|
||||
resp, body = self.client.get_object('workflows', 'wf')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
@ -72,25 +72,16 @@ class WorkflowTestsV2(base.TestCase):
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_update_workflow(self):
|
||||
self.client.create_workflow('wf')
|
||||
resp, body = self.client.update_workflow('wf')
|
||||
self.client.create_workflow()
|
||||
resp, body = self.client.update_workflow()
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertEqual('wfupdated', body['name'])
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_upload_workflow_definition(self):
|
||||
self.client.create_workflow('test_wf')
|
||||
resp, body = self.client.upload_workflow_definition('test_wf')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertIsNotNone(body)
|
||||
self.assertEqual('wf', body['workflows'][0]['name'])
|
||||
|
||||
@test.attr(type='smoke')
|
||||
def test_get_workflow_definition(self):
|
||||
self.client.create_workflow('test')
|
||||
self.client.upload_workflow_definition('test')
|
||||
resp, body = self.client.get_workflow_definition('test')
|
||||
self.client.create_workflow()
|
||||
resp, body = self.client.get_workflow_definition('wf')
|
||||
|
||||
self.assertEqual(200, resp.status)
|
||||
self.assertIsNotNone(body)
|
||||
|
@ -88,7 +88,7 @@ class MistralClientV1(MistralClientBase):
|
||||
return resp, json.loads(body)
|
||||
|
||||
def update_workbook(self, name):
|
||||
post_body = '{"name": "%s"}' % (name + 'updated')
|
||||
post_body = '{"name": "%s"}' % name
|
||||
resp, body = self.put('workbooks/{name}'.format(name=name),
|
||||
post_body)
|
||||
return resp, json.loads(body)
|
||||
@ -202,15 +202,17 @@ class MistralClientV2(MistralClientBase):
|
||||
_version = 2
|
||||
|
||||
def create_workbook(self, name):
|
||||
post_body = '{"name": "%s", "tags": "tag"}' % name
|
||||
resp, body = self.post('workbooks', post_body)
|
||||
text = get_resource('resources/wb_v2.yaml')
|
||||
post_body = {"definition": "%s" % text}
|
||||
resp, body = self.post('workbooks', json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def update_workbook(self, name):
|
||||
post_body = '{"name": "%s", "tags": "tag"}' % (name + 'updated')
|
||||
resp, body = self.put('workbooks/{name}'.format(name=name),
|
||||
post_body)
|
||||
text = get_resource('resources/wb_v2.yaml')
|
||||
post_body = {"definition": "%s" % text}
|
||||
resp, body = self.put('workbooks',
|
||||
json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
@ -219,43 +221,31 @@ class MistralClientV2(MistralClientBase):
|
||||
|
||||
def upload_workbook_definition(self, name):
|
||||
text = get_resource('resources/wb_v2.yaml')
|
||||
post_body = {"name": "%s" % name,
|
||||
"tags": "tag",
|
||||
"definition": "%s" % text}
|
||||
resp, body = self.put('workbooks/{name}'.format(name=name),
|
||||
post_body = {"definition": "%s" % text}
|
||||
resp, body = self.put('workbooks',
|
||||
json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def create_workflow(self, name):
|
||||
def create_workflow(self):
|
||||
text = get_resource('resources/wf_v2.yaml')
|
||||
post_body = {"name": "%s" % name,
|
||||
"definition": "%s" % text,
|
||||
"tags": "tag"}
|
||||
resp, body = self.post('workflows', json.dumps(post_body))
|
||||
post_body = {"definition": "%s" % text}
|
||||
resp, body = self.post('workflows',
|
||||
json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def update_workflow(self, name):
|
||||
post_body = '{"name": "%s", "tags": "tag"}' % (name + 'updated')
|
||||
resp, body = self.put('workflows/{name}'.format(name=name),
|
||||
post_body)
|
||||
def update_workflow(self):
|
||||
text = get_resource('resources/wf_v2.yaml')
|
||||
post_body = {"definition": "%s" % text}
|
||||
resp, body = self.put('workflows',
|
||||
json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def get_workflow_definition(self, name):
|
||||
return self.get('workflows/{name}'.format(name=name))
|
||||
|
||||
def upload_workflow_definition(self, name):
|
||||
text = get_resource('resources/wf_v2.yaml')
|
||||
post_body = {"name": "%s" % name,
|
||||
"tags": "tag",
|
||||
"definition": "%s" % text}
|
||||
resp, body = self.put('workflows/{name}'.format(name=name),
|
||||
json.dumps(post_body))
|
||||
|
||||
return resp, json.loads(body)
|
||||
|
||||
def create_execution(self, wf_name, post_body=None):
|
||||
if post_body is None:
|
||||
body = '{"workflow_name": "%s"}' % wf_name
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
version: '2.0'
|
||||
|
||||
type: direct
|
||||
tasks:
|
||||
hello:
|
||||
action: std.echo output="Hello"
|
||||
publish:
|
||||
result: $
|
||||
wf:
|
||||
type: direct
|
||||
tasks:
|
||||
hello:
|
||||
action: std.echo output="Hello"
|
||||
publish:
|
||||
result: $
|
||||
|
Loading…
Reference in New Issue
Block a user