Commit 804ef74c authored by Joao Pedro Lopes's avatar Joao Pedro Lopes
Browse files
parent ab17d00a
Pipeline #3089736 passed with stages
in 12 minutes and 42 seconds
......@@ -151,7 +151,7 @@ def get(job_list):
Get the job with the given ID
"""
job_ids = job_list.split(",")
multistatus = False
status_error_count = 0
# request is not available inside the generator
environ = request.environ
......@@ -184,8 +184,6 @@ def get(job_list):
setattr(job, "http_status", "200 Ok")
statuses.append(job)
except HTTPException as ex:
if len(job_ids) == 1:
raise
statuses.append(
dict(
job_id=job_id,
......@@ -193,15 +191,21 @@ def get(job_list):
http_message=ex.description,
)
)
multistatus = True
status_error_count += 1
if len(job_ids) == 1:
return statuses[0]
if multistatus:
return Response(statuses, status=207, mimetype="application/json")
res = statuses[0]
if status_error_count == 1:
res = Response(
statuses[0],
status=statuses[0].get("http_status"),
mimetype="application/json",
)
elif status_error_count > 0:
res = Response(statuses, status=207, mimetype="application/json")
else:
return statuses
res = statuses
return res
@jsonify
......
......@@ -79,9 +79,14 @@ class TestJobListing(TestController):
"""
self.setup_gridsite_environment()
error = self.app.get(url="/jobs/1234x", status=404).json
# error_message = json.loads(error['http_message'])
self.assertEqual(error["status"], "404 Not Found")
self.assertEqual(error["message"], 'No job with the id "1234x" has been found')
# self.assertEquals(error['status'], '404 Not Found')
self.assertEquals(error["job_id"], "1234x")
self.assertEquals(error["http_status"], "404 Not Found")
self.assertEquals(
error["http_message"], 'No job with the id "1234x" has been found'
)
def test_list_job_default(self):
"""
......@@ -299,7 +304,7 @@ class TestJobListing(TestController):
UserCredentials.get_granted_level_for = old_granted
self.assertEqual(error["status"], "403 Forbidden")
self.assertEqual(error["http_status"], "403 Forbidden")
def test_get_missing_field(self):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment