2828
2929import json
3030
31- from pytest import mark
31+ from invenio_pidstore . models import PersistentIdentifier
3232from cap .modules .reana .models import ReanaJob
3333
34+ #################
35+ # api/reana/create
36+ #################
37+
38+
39+ def test_create_workflow_returns_404_when_record_does_not_exist (app ,
40+ auth_headers_for_superuser ,
41+ json_headers ):
42+ data = {
43+ 'record_id' : 'wrong_pid' ,
44+ 'workflow_name' : 'test_workflow' ,
45+ 'workflow_json' : {}
46+ }
47+ with app .test_client () as client :
48+ resp = client .post ('/reana/create' , data = json .dumps (data ),
49+ headers = auth_headers_for_superuser + json_headers )
50+
51+ assert resp .status_code == 404
52+
3453
3554#################
3655# api/reana/jobs
3756#################
38- @ mark . skip
39- def test_get_reana_jobs_when_user_not_logged_in_returns_401 (app , users , deposit ):
57+
58+ def test_get_reana_jobs_when_user_not_logged_in_returns_401 (app , users , record ):
4059 with app .test_client () as client :
41- resp = client .get ('/reana/jobs/{}' .format (deposit .id ))
60+ resp = client .get (
61+ '/reana/jobs/{}' .format (record ['_deposit' ]['pid' ]['value' ]))
4262
4363 assert resp .status_code == 401
4464
4565
46- @mark .skip
47- def test_get_reana_jobs_when_depid_doesnt_exists_returns_404 (app ,
66+ def test_get_reana_jobs_when_recid_doesnt_exists_returns_404 (app ,
4867 auth_headers_for_superuser ):
4968 with app .test_client () as client :
5069 resp = client .get ('/reana/jobs/{}' .format ('non-existing-pid' ),
@@ -53,23 +72,24 @@ def test_get_reana_jobs_when_depid_doesnt_exists_returns_404(app,
5372 assert resp .status_code == 404
5473
5574
56- @mark .skip
5775def test_get_reana_jobs_when_no_jobs_returns_empty_list (app , auth_headers_for_superuser ,
58- deposit ):
76+ record ):
5977 with app .test_client () as client :
60- resp = client .get ('/reana/jobs/{}' .format (deposit ['_deposit' ]['id ' ]),
78+ resp = client .get ('/reana/jobs/{}' .format (record ['_deposit' ]['pid' ][ 'value ' ]),
6179 headers = auth_headers_for_superuser )
6280
6381 assert json .loads (resp .data ) == []
6482
6583
66- @mark .skip
6784def test_get_reana_jobs_returns_list_with_user_jobs (db , app , users ,
6885 auth_headers_for_superuser ,
69- deposit ):
86+ record ):
87+
88+ uuid = PersistentIdentifier .get ('recid' , record ['_deposit' ][
89+ 'pid' ]['value' ]).object_uuid
7090 db .session .add (ReanaJob (
71- user = users ['superuser' ],
72- record = deposit . get_record_metadata () ,
91+ user_id = users ['superuser' ]. id ,
92+ record_id = uuid ,
7393 name = 'my_workflow_run' ,
7494 params = {
7595 'param_1' : 1 ,
@@ -78,8 +98,9 @@ def test_get_reana_jobs_returns_list_with_user_jobs(db, app, users,
7898 db .session .commit ()
7999
80100 with app .test_client () as client :
81- resp = client .get ('/reana/jobs/{}' .format (deposit ['_deposit' ]['id' ]),
82- headers = auth_headers_for_superuser )
101+ resp = client .get ('/reana/jobs/{}' .format (
102+ record ['_deposit' ]['pid' ]['value' ]),
103+ headers = auth_headers_for_superuser )
83104
84105 serialized_reana_job = {
85106 'name' : 'my_workflow_run' ,
0 commit comments