Skip to content

Commit 3ae26af

Browse files
committed
fix manager transaction evaluation
1 parent 8778f50 commit 3ae26af

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

pycsw/ogc/api/oapi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import logging
3232

3333
from pycsw import __version__
34+
from pycsw.core.util import str2bool
3435
from pycsw.ogc.api.util import yaml_load
3536

3637
LOGGER = logging.getLogger(__name__)
@@ -429,7 +430,7 @@ def gen_oapi(config, oapi_filepath, mode='ogcapi-records'):
429430
}
430431
}
431432

432-
if config['manager'].get('transactions', False):
433+
if str2bool(config['manager'].get('transactions', False)):
433434
LOGGER.debug('Transactions enabled; adding post')
434435

435436
path['post'] = {
@@ -499,7 +500,7 @@ def gen_oapi(config, oapi_filepath, mode='ogcapi-records'):
499500
}
500501
}
501502

502-
if config['manager'].get('transactions', False):
503+
if str2bool(config['manager'].get('transactions', False)):
503504
LOGGER.debug('Transactions enabled; adding put/delete')
504505

505506
path['put'] = {

pycsw/ogc/api/records.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def landing_page(self, headers_, args):
286286
'type': 'application/json',
287287
'title': 'Main collection',
288288
'href': f"{self.config['server']['url']}/collections/metadata:main"
289-
},{
289+
}, {
290290
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/ogc-catalog',
291291
'type': 'application/json',
292292
'title': 'Record catalogue collection',
@@ -912,7 +912,7 @@ def manage_collection_item(self, headers_, action='create', item=None, data=None
912912
:returns: tuple of headers, status code, content
913913
"""
914914

915-
if not self.config['manager']['transactions']:
915+
if not str2bool(self.config['manager'].get('transactions', False)):
916916
return self.get_exception(
917917
405, headers_, 'InvalidParameterValue',
918918
'transactions not allowed')

tests/functionaltests/suites/oarec/test_oarec_functional.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#
3232
# =================================================================
3333

34+
from copy import deepcopy
3435
import json
3536
from xml.etree import ElementTree as etree
3637

@@ -357,6 +358,33 @@ def test_json_transaction(config, sample_record):
357358

358359
assert status == 404
359360

361+
config2 = deepcopy(config)
362+
config2['manager']['transactions'] = False
363+
364+
api = API(config2)
365+
request_headers = {
366+
'Content-Type': 'application/json'
367+
}
368+
369+
# insert record
370+
headers, status, content = api.manage_collection_item(
371+
request_headers, 'create', data=sample_record)
372+
373+
assert status == 400
374+
375+
config2['manager']['transactions'] = 'false'
376+
377+
api = API(config)
378+
request_headers = {
379+
'Content-Type': 'application/json'
380+
}
381+
382+
# insert record
383+
headers, status, content = api.manage_collection_item(
384+
request_headers, 'create', data=sample_record)
385+
386+
assert status == 400
387+
360388

361389
def test_xml_transaction(config):
362390
api = API(config)

0 commit comments

Comments
 (0)