Exemple #1
0
def test_price_empty_basket():
    b = Basket()
    c = {}
    o = {}

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 0
    assert discount == 0
    assert total == 0
Exemple #2
0
def test_price_basket_buy_three_get_one_free_applicable():
    b = Basket()
    b.add(item_name="peas", count=3)
    c = {"peas": 2.0}
    o = [buy_x_get_y_free("peas", x=3, y=1)]

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 6.0
    assert discount == 2.0
    assert total == 4.0
Exemple #3
0
def test_price_basket_with_a_single_discunted_item():
    b = Basket()
    b.add(item_name="peas", count=1)
    c = {"peas": 2.02}
    o = [discounted_item("peas", 0.5)]

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 2.02
    assert discount == 1.01
    assert total == 1.01
Exemple #4
0
def test_price_basket_with_two_identical_items():
    b = Basket()
    b.add(item_name="peas", count=2)
    c = {"peas": 2.01}
    o = {}

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 4.02
    assert discount == 0
    assert total == 4.02
Exemple #5
0
def test_price_basket_with_single_item():
    b = Basket()
    b.add(item_name="peas")
    c = {"peas": 2.01}
    o = {}

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 2.01
    assert discount == 0
    assert total == 2.01
Exemple #6
0
def test_price_basket_cheapest_of_n_feee_with_two_qalifying_groups():
    b = Basket()
    b.add(item_name="peas", count=3)
    b.add(item_name="shampoo", count=3)
    c = {"peas": 2.0, "shampoo": 1.50}
    o = [cheapest_x_of_n_items_free(items={"peas", "shampoo"}, n=3, x=1)]

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 10.50
    assert discount == 3.50
Exemple #7
0
def test_price_basket_cheapest_of_n_feee_0():
    b = Basket()
    b.add(item_name="peas", count=2)
    b.add(item_name="shampoo", count=1)
    c = {"peas": 2.0, "shampoo": 1.50}
    o = [cheapest_x_of_n_items_free(items={"peas", "shampoo"}, n=3, x=1)]

    sub_total, discount, total = price_basket(basket=b, catalogue=c, offers=o)

    assert sub_total == 5.50
    assert discount == 1.50
    assert total == 4.0