32 lines
907 B
Python
32 lines
907 B
Python
from datetime import date
|
|
|
|
from logic.product_calculator import calculate_discounted_price, get_quantity_label
|
|
|
|
def test_discounted_price_no_orders_in_previous_month_returns_price_with_discount():
|
|
price = 2000
|
|
order_dates = []
|
|
calculation_date = date(2027, 6, 15)
|
|
|
|
result = calculate_discounted_price(price, order_dates, calculation_date)
|
|
|
|
assert result == 1500
|
|
|
|
def test_discounted_price_order_in_previous_month_returns_price_without_discount():
|
|
price = 2000
|
|
order_dates = [date(2027, 5, 10)]
|
|
calculation_date = date(2027, 6, 15)
|
|
|
|
result= calculate_discounted_price(price, order_dates, calculation_date)
|
|
|
|
assert result == 2000
|
|
|
|
def test_quantity_label_five_pairs_returns_few():
|
|
result = get_quantity_label(5)
|
|
|
|
assert result == "мало"
|
|
|
|
def test_quantity_label_six_pairs_return_many():
|
|
result = get_quantity_label(6)
|
|
|
|
assert result == "много"
|