def test_parse_headers6(): t = BaseTransform() t.header_map = {'A': 'FIRST NAME', 'B': 'LAST NAME'} t.headers = ['A', 'B', 'ADDRESS'] t.valid_headers = ['FIRST NAME', 'LAST NAME', 'SKIP'] t.default_not_found = 'SKIP' assert ['FIRST NAME', 'LAST NAME', 'SKIP'] == t.parse_headers()
def test_parse_headers7(): t = BaseTransform() t.header_map = {'A': 'FIRST NAME', 'Column B': 'LAST NAME', 'C': 'NOTES'} t.headers = ['A', 'Column B', 'C'] t.valid_headers = ['FIRST NAME', 'LAST NAME', 'NOTES'] t.prefixable_headers.append('NOTES') assert ['FIRST NAME', 'LAST NAME', 'NOTES'] == t.parse_headers() assert t.column_mods[2].prefix == 'C: '
def test_try_header_variations4(): t = BaseTransform() t.header_map = {'NAME': 'FULL_NAME', 'AME': 'OTHER'} assert (True, 'FULL_NAME') == t.try_header_variations('Full Name', t.header_map, ['FULL_NAME'])
def test_try_header_variations3(): t = BaseTransform() t.header_map = {'COLUMN A': 'NAME'} t._generate_variations = lambda s: [s, 'COLUMN ' + s] assert (True, 'NAME') == t.try_header_variations('a', t.header_map, ['NAME'])
def test_try_header_variations1(): t = BaseTransform() t.header_map = {'0123456789': 'NAME'} assert (False, 'A') == t.try_header_variations('A', t.header_map, ['NAME']) assert (True, 'NAME') == t.try_header_variations('1123456789', t.header_map, ['NAME'])
def test_parse_headers5(): t = BaseTransform() t.header_map = {'A': 'FIRST NAME', 'B': 'LAST NAME'} t.headers = ['A', 'B', 'ADDRESS'] t.valid_headers = ['FIRST NAME', 'LAST NAME', 'ADDRESS'] assert ['FIRST NAME', 'LAST NAME', 'ADDRESS'] == t.parse_headers()
def test_parse_headers4(): t = BaseTransform() t.header_map = {'A': 'NAME', 'B': 'ADDRESS'} t.headers = [None, 'B'] assert ['', 'ADDRESS'] == t.parse_headers()
def test_parse_headers3(): t = BaseTransform() t.header_map = {'A': 'NAME', 'B': 'ADDRESS'} assert t.parse_headers() is None