Skip to content
Snippets Groups Projects
Commit bce6df99 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Fixed type of min and max length for tags

parent bfd3cec4
No related branches found
No related tags found
No related merge requests found
...@@ -117,8 +117,8 @@ def test_tag_name_validator_valid(): ...@@ -117,8 +117,8 @@ def test_tag_name_validator_valid():
def test_tag_length_validator_invalid(): def test_tag_length_validator_invalid():
min = toolkit.config.get('ckanext.odsh.min_tag_length',2) min = int(toolkit.config.get('ckanext.odsh.min_tag_length',2))
max = toolkit.config.get('ckanext.odsh.max_tag_length',100) max = int(toolkit.config.get('ckanext.odsh.max_tag_length',100))
length = round((min + max) / 2) length = round((min + max) / 2)
test_string = _create_test_string(length) test_string = _create_test_string(length)
with pytest.raises(Exception): with pytest.raises(Exception):
...@@ -126,7 +126,7 @@ def test_tag_length_validator_invalid(): ...@@ -126,7 +126,7 @@ def test_tag_length_validator_invalid():
def test_tag_length_validator_valid(): def test_tag_length_validator_valid():
max = toolkit.config.get('ckanext.odsh.max_tag_length',100) max = int(toolkit.config.get('ckanext.odsh.max_tag_length',100))
length = max + 1 length = max + 1
test_string = _create_test_string(length) test_string = _create_test_string(length)
tag_length_validator(test_string, None) tag_length_validator(test_string, None)
......
...@@ -313,8 +313,8 @@ def validate_formats(data, errors): ...@@ -313,8 +313,8 @@ def validate_formats(data, errors):
def tag_length_validator(value, context): def tag_length_validator(value, context):
"""Ensures that tag length is in the acceptable range. """Ensures that tag length is in the acceptable range.
""" """
min_tag_length = tk.config.get('ckanext.odsh.min_tag_length',2) min_tag_length = int(tk.config.get('ckanext.odsh.min_tag_length',2))
max_tag_length = tk.config.get('ckanext.odsh.max_tag_length',100) max_tag_length = int(tk.config.get('ckanext.odsh.max_tag_length',100))
if len(value) < min_tag_length: if len(value) < min_tag_length:
raise toolkit.Invalid( raise toolkit.Invalid(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment