def test_change_drink(): order = Order({ "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": "" }) drink = {"drink_name": "Coke", "number": 2} order.add_drink(drink, menu) order.change_drink({"item_id": 1, "number": 10}, menu, types) expected = { "order_number": 2, "pizzas": [], "drinks": [{ "item_id": 1, "drink_name": "Coke", "number": 10 }], "address": "", "price": 20 } order.change_drink({"item_id": 1, "number": 0}, menu, types) expected = { "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": 0 } assert order.toJSON() == expected
def test_add_pizza(): order = Order({ "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": "" }) pizza = { "size": "M", "type": "pepperoni", "toppings": { "olives": 2 }, "number": 1 } order.add_pizza(pizza, menu) assert order.toJSON() == { "order_number": 2, "pizzas": [{ "item_id": 1, "size": "M", "type": "pepperoni", "toppings": { "olives": 2 }, "number": 1 }], "drinks": [], "address": "", "price": 6 }
def test_recover_an_order(): order = Order(sample_order, menu) assert order.toJSON() == { "order_number": 1, "pizzas": [{ "size": "L", "type": "pepperoni", "toppings": { "olives": 4, "tomatoes": 1, "mushrooms": 1 }, "number": 1, "item_id": 1 }], "drinks": [{ "item_id": 1, "drink_name": "Pepsi", "number": 2 }], "address": "100 Street", "price": 26.5 }
def test_toJSON(): new_order = Order({ "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": "" }) assert new_order.toJSON() == { "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": 0 }
def test_add_drink(): order = Order({ "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": "" }) drink = {"drink_name": "Coke", "number": 3} order.add_drink(drink, menu) assert order.toJSON() == { "order_number": 2, "pizzas": [], "drinks": [{ "item_id": 1, "drink_name": "Coke", "number": 3 }], "address": "", "price": 6 }
def test_change_pizza(): order = Order({ "order_number": 2, "pizzas": [], "drinks": [], "address": "", "price": "" }) pizza = { "size": "M", "type": "pepperoni", "toppings": { "olives": 2, "mushrooms": 1 }, "number": 1 } order.add_pizza(pizza, menu) order.change_pizza({ "item_id": 1, "size": "L", "toppings": { "olives": 0 } }, menu, types) expected = { "order_number": 2, "pizzas": [{ "item_id": 1, "size": "L", "type": "pepperoni", "toppings": { "olives": 2, "mushrooms": 1 }, "number": 1 }], "drinks": [], "address": "", "price": 12.0 } assert order.toJSON() == expected order.change_pizza({ "item_id": 1, "size": "L", "toppings": { "olives": 3 } }, menu, types) expected = { "order_number": 2, "pizzas": [{ "item_id": 1, "size": "L", "type": "pepperoni", "toppings": { "olives": 3, "mushrooms": 1 }, "number": 1 }], "drinks": [], "address": "", "price": 16.5 } assert order.toJSON() == expected