Additional unit tests for REST client

Add unit test for get_task method
This commit is contained in:
Scott Hussey 2017-07-19 11:05:41 -05:00
parent 179459adc0
commit 8431a4aaf9
1 changed files with 28 additions and 2 deletions

View File

@ -83,7 +83,7 @@ def test_session_get():
def test_client_designs_get():
design_id = '828e88dc-6a8b-11e7-97ae-080027ef795a'
responses.add(responses.GET, 'http://foo.bar.baz/api/v1.0/designs',
json=[design_id])
json=[design_id], status=200)
host = 'foo.bar.baz'
token = '5f1e08b6-38ec-4a99-9d0f-00d29c4e325b'
@ -101,7 +101,7 @@ def test_client_design_get():
}
responses.add(responses.GET, 'http://foo.bar.baz/api/v1.0/designs/828e88dc-6a8b-11e7-97ae-080027ef795a',
json=design)
json=design, status=200)
host = 'foo.bar.baz'
@ -113,3 +113,29 @@ def test_client_design_get():
assert design_resp['id'] == design['id']
assert design_resp['model_type'] == design['model_type']
@responses.activate
def test_client_task_get():
task = {'action': 'deploy_node',
'result': 'success',
'parent_task': '444a1a40-7b5b-4b80-8265-cadbb783fa82',
'subtasks': [],
'status': 'complete',
'result_detail': {
'detail': ['Node cab23-r720-17 deployed']
},
'site_name': 'mec_demo',
'task_id': '1476902c-758b-49c0-b618-79ff3fd15166',
'node_list': ['cab23-r720-17'],
'design_id': 'fcf37ba1-4cde-48e5-a713-57439fc6e526'}
host = 'foo.bar.baz'
responses.add(responses.GET, "http://%s/api/v1.0/tasks/1476902c-758b-49c0-b618-79ff3fd15166" % (host),
json=task, status=200)
dd_ses = dc_session.DrydockSession(host)
dd_client = dc_client.DrydockClient(dd_ses)
task_resp = dd_client.get_task('1476902c-758b-49c0-b618-79ff3fd15166')
assert task_resp['status'] == task['status']