diff --git a/ckanext/data_qld/converters.py b/ckanext/data_qld/converters.py index 402f0a5a..79a53f66 100644 --- a/ckanext/data_qld/converters.py +++ b/ckanext/data_qld/converters.py @@ -12,6 +12,8 @@ def filesize_converter(value, context): :rtype: int """ + if not value: + return None value = str(value) # remove whitespaces value = re.sub(' ', '', value) diff --git a/ckanext/data_qld/tests/test_converters.py b/ckanext/data_qld/tests/test_converters.py index aa53c6b8..e2d1d491 100644 --- a/ckanext/data_qld/tests/test_converters.py +++ b/ckanext/data_qld/tests/test_converters.py @@ -14,6 +14,8 @@ def test_filesize_converter(): '2 kb': 2048, 1024: 1024, '1024, ': 1024, + '1,000 bytes': 1000, + '1,000 MB': 1048576000, } for key, value in six.iteritems(test_cases): assert value == filesize_converter(key, {})