def order_2(): return Order( barista='txema', hamburgers=[ Hamburger( meats=[ Meat( type='cerdo', size='250g', cooked='al punto', ), Meat( type='cerdo', size='380g', cooked='al punto', ), ], extra_tomato=ExtraTomato(type='normal', ), ), ], chips=[ Chips( type='de la abuela', size='grandes', ), ], drinks=[ Drink(type='burribeer', ), ], )
def test_calculate_prices_2(order_2): expected = Order( barista='txema', hamburgers=[ Hamburger( meats=[ Meat( type='cerdo', size='250g', cooked='al punto', price=2.5, ), Meat( type='cerdo', size='380g', cooked='al punto', price=3.5, ), ], extra_tomato=ExtraTomato( type='normal', price=1.0, ), price=12.0 * (100 - 15) / 100, ), ], chips=[ Chips( type='de la abuela', size='grandes', price=3.5, ), ], drinks=[ Drink( type='burribeer', price=2.5, ), ], price=16.2, promotions=['burrimenu'], ) result = orders.calculate_prices(order=order_2) assert_dicts(original=result.dict(), expected=expected.dict())
def test_calculate_prices_promotion_burrimenu(order_promotion_menu): expected = Order( barista='txema', hamburgers=[ Hamburger( meats=[ Meat( type='pollo', size='250g', cooked='al punto', price=2.5, ) ], extra_cheese=ExtraCheese( type='cheddar', price=1.5, ), extra_tomato=ExtraTomato( type='normal', price=1.0, ), price=10.0 * (100 - 15) / 100, ), ], chips=[ Chips( type='gajo', size='pequeñas', price=2.5, ), ], drinks=[ Drink( type='burribeer', price=2.5, ), ], price=13.5, promotions=['burrimenu'], ) assert PromotionBurrimenu().is_applicable( order=order_promotion_menu) is True result = orders.calculate_prices(order=order_promotion_menu) assert_dicts(original=result.dict(), expected=expected.dict())
def calculate( self, meat: Meat ) -> float: """ Calculate price for a meat. :param Meat meat: meat :return float: price """ result = 0.0 if meat.size == '125g': result = 2.0 elif meat.size == '250g': result = 2.5 elif meat.size == '380g': result = 3.5 meat.price = result return result
def order_1(): return Order( barista='txema', hamburgers=[ Hamburger( meats=[Meat( type='pollo', size='250g', cooked='al punto', )], extra_cheese=ExtraCheese(type='cheddar', ), extra_tomato=ExtraTomato(type='normal', ), ), ], chips=[ Chips( type='gajo', size='pequeñas', ), ], promotions=[], )
def test_calculate_prices_1(order_1): expected = Order( barista='txema', hamburgers=[ Hamburger( meats=[ Meat( type='pollo', size='250g', cooked='al punto', price=2.5, ) ], extra_cheese=ExtraCheese( type='cheddar', price=1.5, ), extra_tomato=ExtraTomato( type='normal', price=1.0, ), price=10.0, ), ], chips=[ Chips( type='gajo', size='pequeñas', price=2.5, ), ], price=12.5, promotions=[], ) result = orders.calculate_prices(order=order_1) assert_dicts(original=result.dict(), expected=expected.dict())