def test_data_population_returns_list_of_dicts():
    fake_headers = ['one', 'two', 'three']
    fake_data = [['a', 'b', 'c'], ['1', '2', '3']]
    populated = utilities.data_population(fake_data, fake_headers)
    assert type(populated) == list
    assert type(populated[0]) == dict
    assert len(populated) == 2
def ods_ezodf(fp):
    """Read and convert a ods file to JSON format using the ezodf library
    :param fp: File pointer object
    :return: tuple of table headers and data
    """

    workbook = ezodf.opendoc(fp.name)
    sheet = workbook.sheets[0]

    list_data = [[cell.value for cell in row] for row in sheet.rows()]

    header = header_population(list_data[0])
    data = data_population(list_data)

    return header, data
def csv_csv(fp):
    """Read and convert a csv file to JSON format using the csv library
    :param fp: File pointer object
    :return: tuple of table headers and data
    """

    dialect = csv.Sniffer().sniff((fp).read(1024))
    fp.seek(0)
    reader = csv.reader(fp, dialect)
    complete_data = [row for row in reader]

    # Assume that the first line is the header, other lines are data
    header = header_population(complete_data[0])
    data = data_population(complete_data[1:], complete_data[0])

    return header, data
def test_data_population_without_headers():
    fake_data = [['one', 'two', 'three'], ['a', 'b', 'c'], ['1', '2', '3']]
    populated = utilities.data_population(fake_data)
    assert type(populated) == list
    assert type(populated[0]) == dict
    assert len(populated) == 3