csv-metadata-quality/tests/test_fix.py

59 lines
1.1 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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'
def test_fix_unnecessary_unicode():
'''Test fixing unnecessary Unicode.'''
value = 'Alan Orth'
assert fix.unnecessary_unicode(value) == 'Alan Orth'
def test_fix_duplicates():
'''Test fixing duplicate metadata values.'''
value = 'Kenya||Kenya'
assert fix.duplicates(value) == 'Kenya'
def test_fix_newlines():
'''Test fixing newlines.'''
value = '''Ken
ya'''
assert fix.newlines(value) == 'Kenya'