Skip to content

Commit

Permalink
[QOLSVC-3826] Check for None before converting to string, and adding …
Browse files Browse the repository at this point in the history
…more unit test cases
  • Loading branch information
RossWebsterWork committed Nov 22, 2023
1 parent ec59359 commit 67c56df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ckanext/data_qld/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions ckanext/data_qld/tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {})

0 comments on commit 67c56df

Please sign in to comment.