Skip to content

Commit

Permalink
tests: add test for getting status endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Rodriguez <diego.rodriguez@cern.ch>
  • Loading branch information
Diego Rodriguez committed Nov 3, 2017
1 parent bda3815 commit c6e8779
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,60 @@ def test_get_workflow_outputs_file_with_path(app, db_session, default_user,
content_type='application/json',
data=json.dumps(data))
assert res.data == file_binary_content


def test_get_workflow_status(app, db_session, default_user):
"""Test get workflow status."""
with app.test_client() as client:
# create workflow
organization = 'default'
data = {'parameters': {'min_year': '1991',
'max_year': '2001'},
'specification': {'first': 'do this',
'second': 'do that'},
'type': 'cwl'}
# create first test workflow with default status
res = client.post(url_for('api.create_workflow'),
query_string={
"user": default_user.id_,
"organization": organization},
content_type='application/json',
data=json.dumps(data))

response_data = json.loads(res.get_data(as_text=True))
workflow1_uuid = response_data.get('workflow_id')
workflow1 = Workflow.query.filter(
Workflow.id_ == workflow1_uuid).first()

res = client.get(url_for('api.get_workflow_status',
workflow_id=workflow1_uuid),
query_string={
"user": default_user.id_,
"organization": organization},
content_type='application/json',
data=json.dumps(data))
json_response = json.loads(res.data.decode())
assert json_response.get('status') == workflow1.status.name
# create second test workflow modifying status
res = client.post(url_for('api.create_workflow'),
query_string={
"user": default_user.id_,
"organization": organization},
content_type='application/json',
data=json.dumps(data))
response_data = json.loads(res.get_data(as_text=True))
workflow2_uuid = response_data.get('workflow_id')
workflow2 = Workflow.query.filter(
Workflow.id_ == workflow2_uuid).first()
workflow2.status = WorkflowStatus.finished
db_session.commit()

res = client.get(url_for('api.get_workflow_status',
workflow_id=workflow2_uuid),
query_string={
"user": default_user.id_,
"organization": organization},
content_type='application/json',
data=json.dumps(data))
json_response = json.loads(res.data.decode())
assert json_response.get('status') == workflow2.status.name

0 comments on commit c6e8779

Please sign in to comment.