コード例 #1
0
def test_calc_cost_to_own_ioniq(df_filtered_cars):
    auto = "hyundai ioniq hybrid plugin"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        assert car[Column.MY_M_COSTS] > 400
        assert car[Column.MY_M_COSTS] < 600
コード例 #2
0
def test_euro_columns(df_filtered_cars):
    df = _get_df_with_cost_to_own(filtered_cars=df_filtered_cars)
    for col in df.columns:
        for i, row in df.iterrows():
            val = row[col]
            if type(val) == str:
                assert "euro" not in row[col].lower(), f"Found euro in '{col}'"
コード例 #3
0
def test_calc_cost_to_own_corsa(df_filtered_cars):
    auto = "opel corsa"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        assert 300 < car[Column.MY_M_COSTS] < 500
        assert car[Column.ACCELERATION] < 11
コード例 #4
0
def test_calc_cost_to_own_ceed(df_filtered_cars):
    auto = "kia ceed"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        assert car[Column.MY_M_COSTS] > 300
        assert car[Column.MY_M_COSTS] < 550
        assert car[Column.ACCELERATION] < 12
コード例 #5
0
def test_calc_cost_to_own_corsa_e_with_german_discount(df_filtered_cars):
    auto = "opel corsa-e"
    df = _get_df_with_cost_to_own(auto,
                                  de_discount=True,
                                  filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        is_electric = car["Motorart"] == "Elektro"
        if is_electric:
            assert car[Column.TOTAL_PRICE] < car[Column.PRICE]
        else:
            assert car[Column.TOTAL_PRICE] >= car[Column.PRICE]
コード例 #6
0
def test_calc_cost_to_own_ioniq_with_german_discount(df_filtered_cars):
    auto = "hyundai ioniq"
    df = _get_df_with_cost_to_own(auto,
                                  de_discount=True,
                                  filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        is_electric = car["Motorart"] in ["PlugIn-Hybrid", "Elektro"]
        if is_electric:
            assert car[Column.TOTAL_PRICE] < car[Column.PRICE]
        else:
            assert (pd.isna(car[Column.TOTAL_PRICE])
                    or car[Column.TOTAL_PRICE] >= car[Column.PRICE])
コード例 #7
0
def test_calc_cost_to_own_208(df_filtered_cars):
    auto = "Peugeot 208"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for _, car in df.iterrows():
        assert 300 < car[Column.MY_M_COSTS] < 510
        capacity = car[Column.BATTERY_CAPACITY]
        tank = car[Column.FUEL_TANK_SIZE]
        if car[Column.ENGINE_TYPE] == "Elektro":
            assert pd.notna(capacity)
            assert pd.isna(tank)
        else:
            assert pd.notna(tank)
            assert pd.isna(capacity)
コード例 #8
0
def test_calc_cost_to_own(df_filtered_cars):
    auto = "subaru impreza"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
    for index, car in df.iterrows():
        assert car[Column.MY_M_COSTS] > 500
        assert car[Column.MY_M_COSTS] < 700
        assert car[Column.ACCELERATION] < 13
        assert car[Column.ACCELERATION] > 8
        assert car[Column.RANGE] > 500
        assert car[Column.TOTAL_PRICE] > 0

    assert not df[df[Column.NAME].str.contains(
        "Subaru Impreza 2.0i Exclusive")].empty
コード例 #9
0
def test_missing_features_in_adac(df_filtered_cars):
    df_input = pd.read_excel(
        os.path.join(os.path.dirname(__file__), "cars.xlsx"))
    cols = set(["name"] + df_input["adac column"].dropna().to_list()) - set(
        "LED-Scheinwerfer,Navigation,Querverkehrassistent,Aktive Kopfstützen,Fußgängererkennung,Kurvenlicht,Notbremsassistent,Spurhalteassistent,Stauassistent,Verkehrsschild-Erkennung"
        .split(","))
    df = _get_df_with_cost_to_own(filtered_cars=df_filtered_cars)

    df_bad = pd.DataFrame()
    for i, row in df[cols].iterrows():
        nas = row[pd.isna(row[cols])]
        s_row = row.filter(["name"]).append(nas)
        if nas.size > 0:
            df_bad = df_bad.append(s_row, ignore_index=True)
    df_bad.to_excel("/tmp/bad.xlsx")
    assert df_bad.shape[0] / float(df.shape[0]) < 0.10
コード例 #10
0
def test_calc_cost_to_own_3008(df_filtered_cars):
    auto = "peugeot 3008"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) >= 2
コード例 #11
0
def test_calc_cost_to_own_bmw_1(df_filtered_cars):
    auto = "Bmw 1"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert len(df) > 1
コード例 #12
0
def test_calc_cost_to_own_mb_a(df_filtered_cars):
    auto = "Mercedes A"
    df = _get_df_with_cost_to_own(auto, filtered_cars=df_filtered_cars)
    assert not df[df[Column.NAME].str.contains("Mercedes A")].empty