예제 #1
0
def test_split_into_long_and_normal_lists():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    long, short = main.split_into_long_and_normal_lists(data_list=data,
                                                        mater=list(),
                                                        vehicles=list())
    assert len(short) == 7
    assert len(long) == 2
예제 #2
0
def test_insert_into_table():
    engine = utils.get_db_engine()
    Temp_table.__table__.create(bind=engine, checkfirst=True)

    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    long, short = main.split_into_long_and_normal_lists(data_list=data,
                                                        mater=list(),
                                                        vehicles=list())

    test_short = list()
    for row in short:
        test_short.append(row[:3])
    test_short.append(test_short[6])

    main.insert_into_table(data_list=test_short,
                           table=Temp_table,
                           engine=engine)

    length = engine.execute("SELECT COUNT(*) FROM test_table").scalar()
    Temp_table.__table__.drop(bind=engine)

    assert length == 7
예제 #3
0
def test_make_long_enough_longer():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    fixed_row = main.make_long_enough(data[7])
    assert len(fixed_row) == 40
예제 #4
0
def test_fix_short_row_correct():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    fixed_row = main.fix_short_row(data[8])
    assert len(fixed_row) == 36
예제 #5
0
def test_read_csv_all_rows():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    assert len(data) == 9
예제 #6
0
def test_read_csv_rest_not_upper():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    assert data[0][3] == "should_lower_case"
예제 #7
0
def test_read_csv_pk_upper():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    assert data[0][2] != "shouldnt_lower_case"
예제 #8
0
def test_read_csv_no_header():
    data = main.read_data_from_csv(source="test/vehicle.csv0001_part_00")
    assert data[0][0] == "LPAE"
    assert data[0][0] != "country"