2019-07-27 00:36:40 +03:00
|
|
|
|
import csv_metadata_quality.fix as fix
|
|
|
|
|
|
2019-07-28 17:47:28 +03:00
|
|
|
|
|
2019-07-27 00:36:40 +03:00
|
|
|
|
def test_fix_leading_whitespace():
|
|
|
|
|
'''Test fixing leading whitespace.'''
|
|
|
|
|
|
|
|
|
|
value = ' Alan'
|
|
|
|
|
|
|
|
|
|
assert fix.whitespace(value) == 'Alan'
|
|
|
|
|
|
2019-07-28 17:47:28 +03:00
|
|
|
|
|
2019-07-27 00:36:40 +03:00
|
|
|
|
def test_fix_trailing_whitespace():
|
|
|
|
|
'''Test fixing trailing whitespace.'''
|
|
|
|
|
|
|
|
|
|
value = 'Alan '
|
|
|
|
|
|
|
|
|
|
assert fix.whitespace(value) == 'Alan'
|
|
|
|
|
|
2019-07-28 17:47:28 +03:00
|
|
|
|
|
2019-07-27 00:36:40 +03:00
|
|
|
|
def test_fix_excessive_whitespace():
|
|
|
|
|
'''Test fixing excessive whitespace.'''
|
|
|
|
|
|
|
|
|
|
value = 'Alan Orth'
|
|
|
|
|
|
|
|
|
|
assert fix.whitespace(value) == 'Alan Orth'
|
2019-07-28 22:53:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_fix_invalid_separators():
|
|
|
|
|
'''Test fixing invalid multi-value separators.'''
|
|
|
|
|
|
|
|
|
|
value = 'Alan|Orth'
|
|
|
|
|
|
|
|
|
|
assert fix.separators(value) == 'Alan||Orth'
|
2019-07-29 16:38:10 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_fix_unnecessary_unicode():
|
|
|
|
|
'''Test fixing unnecessary Unicode.'''
|
|
|
|
|
|
|
|
|
|
value = 'Alan Orth'
|
|
|
|
|
|
|
|
|
|
assert fix.unnecessary_unicode(value) == 'Alan Orth'
|
2019-07-29 18:05:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_fix_duplicates():
|
|
|
|
|
'''Test fixing duplicate metadata values.'''
|
|
|
|
|
|
|
|
|
|
value = 'Kenya||Kenya'
|
|
|
|
|
|
|
|
|
|
assert fix.duplicates(value) == 'Kenya'
|
2019-07-30 20:05:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_fix_newlines():
|
|
|
|
|
'''Test fixing newlines.'''
|
|
|
|
|
|
|
|
|
|
value = '''Ken
|
|
|
|
|
ya'''
|
|
|
|
|
|
|
|
|
|
assert fix.newlines(value) == 'Kenya'
|