Skip to content

Commit cb80d00

Browse files
committed
fix
1 parent 38b376a commit cb80d00

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pycsw/ogc/api/records.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,12 +1283,16 @@ def record2json(record, url, collection, mode='ogcapi-records'):
12831283
# OWSlib currently uses .keywords_object for keywords with url, see https://github.com/geopython/OWSLib/pull/765
12841284
try:
12851285
for theme in json.loads(record.themes):
1286-
print("THEME", theme)
12871286
try:
1288-
ogcapi_themes.append({
1289-
'scheme': theme['thesaurus'].get('url') or theme['thesaurus'].get('title'),
1287+
theme_ = {
12901288
'concepts': [{'id': c.get('name', '')} for c in theme.get('keywords', []) if 'name' in c and c['name'] not in [None, '']]
1291-
})
1289+
}
1290+
if 'thesaurus' in theme:
1291+
theme_['scheme'] = theme['thesaurus'].get('url') or theme['thesaurus'].get('title'),
1292+
elif 'scheme' in theme:
1293+
theme_['scheme'] = theme['scheme']
1294+
1295+
ogcapi_themes.append(theme_)
12921296
except Exception as err:
12931297
LOGGER.exception(f"failed to parse theme of {record.identifier}: {err}")
12941298
except Exception as err:

tests/functionaltests/suites/oarec/test_oarec_functional.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def test_items(config):
132132

133133
params = {'q': 'Lorem'}
134134
content = json.loads(api.items({}, None, params)[2])
135+
135136
assert content['numberMatched'] == 5
136137
assert content['numberReturned'] == 5
137138
assert len(content['features']) == content['numberReturned']
@@ -366,20 +367,20 @@ def test_json_transaction(config, sample_record):
366367
'Content-Type': 'application/json'
367368
}
368369

369-
# insert record
370+
# fail on insert record attempt
370371
headers, status, content = api.manage_collection_item(
371372
request_headers, 'create', data=sample_record)
372373

373374
assert status == 405
374375

375376
config2['manager']['transactions'] = 'false'
376377

377-
api = API(config)
378+
api = API(config2)
378379
request_headers = {
379380
'Content-Type': 'application/json'
380381
}
381382

382-
# insert record
383+
# fail on insert record attempt
383384
headers, status, content = api.manage_collection_item(
384385
request_headers, 'create', data=sample_record)
385386

0 commit comments

Comments
 (0)