def test_shipping_costs(self): # test FedEx shipping order = Order() strategy = FedExStrategy() shipping_cost = ShippingCost(strategy) cost = shipping_cost.calculate(order) assert cost == 3.0 # test UPS shipping order = Order() strategy = UPSStrategy() shipping_cost = ShippingCost(strategy) cost = shipping_cost.calculate(order) assert cost == 4.0 # test Postal Service shipping order = Order() strategy = PostalStrategy() shipping_cost = ShippingCost(strategy) cost = shipping_cost.calculate(order) assert cost == 5.0
from strategy import Order, ShippingCost from strategy import FedexStrategy, UPSStrategy, PostalStrategy # Test Fedex shipping order = Order() strategy = FedexStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost(order) assert cost == 3.0 # Test UPS shipping order = Order() strategy = UPSStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost(order) assert cost == 4.0 # Test Postal shipping order = Order() strategy = PostalStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost(order) assert cost == 5.0 print('tests passed')
from strategy import Order, ShippingCost from strategy import FedExStrategy, PostalStrategy, UPSStrategy #Test federal exprass shipping order = Order("papas") strategy = FedExStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost_calc(order) print(order.container) assert cost == 3.0 #Test UPS shipping order = Order("papas") strategy = UPSStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost_calc(order) assert cost == 4.0 #Test Postal Service shipping order = Order("papas") strategy = PostalStrategy() cost_calculator = ShippingCost(strategy) cost = cost_calculator.shipping_cost_calc(order) assert cost == 5.0 print("Test passed")
def test_large_order_promo_with_discount(customer_fidelity_0) -> None: cart = [LineItem(str(item_code), 1, 1.0) for item_code in range(10)] order = Order(customer_fidelity_0, cart, large_order_promo) assert order.total() == 10.0 assert order.due() == 9.3
def test_large_order_promo_no_discount(customer_fidelity_0, cart_plain) -> None: order = Order(customer_fidelity_0, cart_plain, large_order_promo) assert order.total() == 42.0 assert order.due() == 42.0
def test_bulk_item_promo_with_discount(customer_fidelity_0) -> None: cart = [LineItem('banana', 30, 0.5), LineItem('apple', 10, 1.5)] order = Order(customer_fidelity_0, cart, bulk_item_promo) assert order.total() == 30.0 assert order.due() == 28.5
def test_fidelity_promo_with_discount(customer_fidelity_1100, cart_plain) -> None: order = Order(customer_fidelity_1100, cart_plain, fidelity_promo) assert order.total() == 42.0 assert order.due() == 39.9