1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2024-11-18 12:07:03 +01:00
csv-metadata-quality/tests/test_fix.py
Alan Orth 40e77db713
Add "unsafe fixes" runtime option
In this case it fixes occurences of invalid multi-value separators.
DSpace uses "||" to separate multiple values in one field, but our
editors sometimes give us files with mistakes like "|". We can fix
these to be correct multi-value separators if we are sure that the
metadata is not actually using "|" for some legitimate purpose.
2019-07-28 22:53:39 +03:00

34 lines
653 B
Python

import csv_metadata_quality.fix as fix
def test_fix_leading_whitespace():
'''Test fixing leading whitespace.'''
value = ' Alan'
assert fix.whitespace(value) == 'Alan'
def test_fix_trailing_whitespace():
'''Test fixing trailing whitespace.'''
value = 'Alan '
assert fix.whitespace(value) == 'Alan'
def test_fix_excessive_whitespace():
'''Test fixing excessive whitespace.'''
value = 'Alan Orth'
assert fix.whitespace(value) == 'Alan Orth'
def test_fix_invalid_separators():
'''Test fixing invalid multi-value separators.'''
value = 'Alan|Orth'
assert fix.separators(value) == 'Alan||Orth'