Skip to content

Commit

Permalink
add return type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesha123 committed Jan 24, 2024
1 parent 4a39345 commit 2780a2a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@
def test_small_order_surcharge(mock_delivery_data, mock_surcharge):
for i, data in enumerate(mock_delivery_data):
delivery_data = from_dict(data_class=DeliveryFeeRequest, data=data)
assert small_order_surcharge(delivery_data.cart_value) == mock_surcharge[i]
value = small_order_surcharge(delivery_data.cart_value)
assert value == mock_surcharge[i] and type(value) == int


def test_distance_delivery_fee(mock_delivery_data, mock_distance_fee):
for i, data in enumerate(mock_delivery_data):
delivery_data = from_dict(data_class=DeliveryFeeRequest, data=data)
assert distance_delivery_fee(delivery_data.delivery_distance) == mock_distance_fee[i]
value = distance_delivery_fee(delivery_data.delivery_distance)
assert value == mock_distance_fee[i] and type(value) == int


def test_item_delivery_fee(mock_delivery_data, mock_item_fee):
for i, data in enumerate(mock_delivery_data):
delivery_data = from_dict(data_class=DeliveryFeeRequest, data=data)
assert item_delivery_fee(delivery_data.number_of_items) == mock_item_fee[i]
value = item_delivery_fee(delivery_data.number_of_items)
assert value == mock_item_fee[i] and type(value) == int


def test_is_free_delivery(mock_delivery_data, mock_is_free_delivery):
for i, data in enumerate(mock_delivery_data):
delivery_data = from_dict(data_class=DeliveryFeeRequest, data=data)
assert is_free_delivery(delivery_data.cart_value) == mock_is_free_delivery[i]
value = is_free_delivery(delivery_data.cart_value)
assert value == mock_is_free_delivery[i] and type(value) == bool


def test_friday_rush_delivery(mock_delivery_data, mock_friday_rush_fee):
Expand All @@ -41,13 +46,15 @@ def test_friday_rush_delivery(mock_delivery_data, mock_friday_rush_fee):
surcharge = small_order_surcharge(delivery_data.cart_value)
distance_fee = distance_delivery_fee(delivery_data.delivery_distance)
item_fee = item_delivery_fee(delivery_data.number_of_items)
assert friday_rush_delivery(surcharge+distance_fee+item_fee, delivery_data.time) == mock_friday_rush_fee[i]
value = friday_rush_delivery(surcharge+distance_fee+item_fee, delivery_data.time)
assert value == mock_friday_rush_fee[i] and type(value) == int


def test_delivery_fee_calculator(mock_delivery_data, mock_delivery_fee):
for i, data in enumerate(mock_delivery_data):
delivery_data = from_dict(data_class=DeliveryFeeRequest, data=data)
assert delivery_fee(delivery_data) == mock_delivery_fee[i]
value = delivery_fee(delivery_data)
assert value == mock_delivery_fee[i] and type(value) == int


def test_delivery_fee_calculator_failed(mock_delivery_data, mock_delivery_fee):
Expand Down

0 comments on commit 2780a2a

Please sign in to comment.