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