Skip to content
Snippets Groups Projects
Commit 4076fc5c authored by Sabine Schröder's avatar Sabine Schröder
Browse files

avoid an internal server error when an unknown request id is passed to the...

avoid an internal server error when an unknown request id is passed to the endpoint 'request_timeseries_list_of_contributors'
parent 4e3cd96f
No related branches found
No related tags found
2 merge requests!224preparation for testing the (re-)integrated AAI; started strictly separating...,!223preparation for testing the (re-)integrated AAI; making toar2_category available
Pipeline #251841 passed
...@@ -1084,6 +1084,14 @@ class TestApps: ...@@ -1084,6 +1084,14 @@ class TestApps:
assert response.json() == expected_response assert response.json() == expected_response
def test_request_registered_contributors_list_unknown_rid(self, client, db):
response = client.get("/timeseries/request_timeseries_list_of_contributors/7f0df73a-bd0f-58b9-bb17-d5cd36f89598?format=text")
expected_status_code = 400
assert response.status_code == expected_status_code
expected_response = 'not a registered request id: 7f0df73a-bd0f-58b9-bb17-d5cd36f89598'
assert response.json() == expected_response
# 3. tests updating timeseries metadata # 3. tests updating timeseries metadata
def test_patch_timeseries_no_description(self, client, db): def test_patch_timeseries_no_description(self, client, db):
......
...@@ -618,9 +618,14 @@ def get_request_contributors(db: Session, format: str = 'text', input_handle: Up ...@@ -618,9 +618,14 @@ def get_request_contributors(db: Session, format: str = 'text', input_handle: Up
def get_registered_request_contributors(db: Session, rid, format: str = 'text'): def get_registered_request_contributors(db: Session, rid, format: str = 'text'):
try:
timeseries_ids = db.execute(select([s1_contributors_table]).\ timeseries_ids = db.execute(select([s1_contributors_table]).\
where(s1_contributors_table.c.request_id == rid)).mappings().first()['timeseries_ids'] where(s1_contributors_table.c.request_id == rid)).mappings().first()['timeseries_ids']
return get_contributors_list(db, timeseries_ids, format) return get_contributors_list(db, timeseries_ids, format)
except:
status_code=400
message=f"not a registered request id: {rid}"
return JSONResponse(status_code=status_code, content=message)
def register_request_contributors(db: Session, rid, ids): def register_request_contributors(db: Session, rid, ids):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment