Merge pull request #1120 from tomkralidis/issue-1117

add links to process list endpoint (#1117)
This commit is contained in:
Tom Kralidis
2023-01-28 16:58:10 -05:00
committed by GitHub
2 changed files with 21 additions and 3 deletions
+19 -2
View File
@@ -6,7 +6,7 @@
# John A Stevenson <jostev@bgs.ac.uk>
# Colin Blackburn <colb@bgs.ac.uk>
#
# Copyright (c) 2022 Tom Kralidis
# Copyright (c) 2023 Tom Kralidis
# Copyright (c) 2022 Francesco Bartoli
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
#
@@ -3168,8 +3168,25 @@ class API:
if process is not None:
response = processes[0]
else:
process_url = f"{self.config['server']['url']}/processes"
response = {
'processes': processes
'processes': processes,
'links': [{
'type': FORMAT_TYPES[F_JSON],
'rel': request.get_linkrel(F_JSON),
'title': 'This document as JSON',
'href': f'{process_url}?f={F_JSON}'
}, {
'type': FORMAT_TYPES[F_JSONLD],
'rel': request.get_linkrel(F_JSONLD),
'title': 'This document as RDF (JSON-LD)',
'href': f'{process_url}?f={F_JSONLD}'
}, {
'type': FORMAT_TYPES[F_HTML],
'rel': request.get_linkrel(F_HTML),
'title': 'This document as HTML',
'href': f'{process_url}?f={F_HTML}'
}]
}
if request.format == F_HTML: # render
+2 -1
View File
@@ -4,7 +4,7 @@
# John A Stevenson <jostev@bgs.ac.uk>
# Colin Blackburn <colb@bgs.ac.uk>
#
# Copyright (c) 2022 Tom Kralidis
# Copyright (c) 2023 Tom Kralidis
# Copyright (c) 2022 John A Stevenson and Colin Blackburn
#
# Permission is hereby granted, free of charge, to any person
@@ -1343,6 +1343,7 @@ def test_describe_processes(config, api_):
data = json.loads(response)
assert code == HTTPStatus.OK
assert len(data['processes']) == 1
assert len(data['links']) == 3
# Test for particular, defined process
rsp_headers, code, response = api_.describe_processes(req, 'hello-world')