Esempio n. 1
0
def test_setheader():

    table1 = (('foo', 'bar'), ('a', 1), ('b', 2))
    table2 = setheader(table1, ['foofoo', 'barbar'])
    expect2 = (('foofoo', 'barbar'), ('a', 1), ('b', 2))
    ieq(expect2, table2)
    ieq(expect2, table2)  # can iterate twice?
Esempio n. 2
0
def test_setheader():

    table1 = (("foo", "bar"), ("a", 1), ("b", 2))
    table2 = setheader(table1, ["foofoo", "barbar"])
    expect2 = (("foofoo", "barbar"), ("a", 1), ("b", 2))
    ieq(expect2, table2)
    ieq(expect2, table2)  # can iterate twice?
Esempio n. 3
0
def test_setheader():

    table1 = (('foo', 'bar'),
              ('a', 1),
              ('b', 2))
    table2 = setheader(table1, ['foofoo', 'barbar'])
    expect2 = (('foofoo', 'barbar'),
               ('a', 1),
               ('b', 2))
    ieq(expect2, table2)
    ieq(expect2, table2)  # can iterate twice?
Esempio n. 4
0
def _fix_missing_headers(table, schema):
    '''add missing columns headers from schema'''
    if schema is None or 'fields' not in schema:
        return table
    # table2: try not advance iterators
    sample, table2 = iterpeek(table, 2)
    cols = fieldnames(sample)
    headers = _get_schema_header_names(schema)
    if len(cols) >= len(headers):
        return table2
    table3 = setheader(table2, headers)
    return table3
Esempio n. 5
0
def _fix_missing_headers(table, schema):
    '''add missing columns headers from schema'''
    if schema is None or not 'fields' in schema:
        return table
    # table2: try not advance iterators
    sample, table2 = iterpeek(table, 2)
    cols = fieldnames(sample)
    fields = schema.get('fields')
    if len(cols) >= len(fields):
        return table2
    header = [field.get('name') for field in fields]
    table3 = setheader(table2, header)
    return table3
Esempio n. 6
0
def test_setheader_empty():

    table1 = (('foo', 'bar'),)
    table2 = setheader(table1, ['foofoo', 'barbar'])
    expect2 = (('foofoo', 'barbar'),)
    ieq(expect2, table2)
Esempio n. 7
0
def test_setheader_empty():

    table1 = (('foo', 'bar'), )
    table2 = setheader(table1, ['foofoo', 'barbar'])
    expect2 = (('foofoo', 'barbar'), )
    ieq(expect2, table2)
Esempio n. 8
0
def test_setheader_empty():

    table1 = (("foo", "bar"),)
    table2 = setheader(table1, ["foofoo", "barbar"])
    expect2 = (("foofoo", "barbar"),)
    ieq(expect2, table2)