def test_sides(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) fries1 = order1.Create_Item("fries") fries1.Size = "medium" order1.Add_To_Order(fries1) assert(fries1 in order1.Items) assert(order1.Calculate_Cost() == 3) nuggets1 = order1.Create_Item("nuggets") nuggets1.Size = "medium" order1.Add_To_Order(nuggets1) assert(nuggets1 in order1.Items) assert(order1.Calculate_Cost() == 10)
def test_create_and_add_item(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) orig_white_bun = inventory_fixture["white"] orig_beef = inventory_fixture["beef"] orig_cheese = inventory_fixture["cheese"] burg1 = order1.Create_Item("Burger") burg1.Bun_Type = "white" burg1.Add_Bun() burg1.Add_Bun() burg1.Patty_Type = "beef" burg1.Add_Patty() burg1.Add_Other("cheese") assert(inventory_fixture["white"] == (orig_white_bun - 2)) assert(inventory_fixture["beef"] == (orig_beef - 1)) assert(inventory_fixture["cheese"] == (orig_cheese - 1)) assert(order1.Calculate_Cost() == 0) order1.Add_To_Order(burg1) assert(burg1 in order1.Items) assert(order1.Calculate_Cost() == 9)
def test_default_wrap(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) orig_pita = inventory_fixture["pita"] orig_pork = inventory_fixture["pork"] orig_cheese = inventory_fixture["cheese"] orig_tortilla = inventory_fixture["tortilla"] orig_tuna = inventory_fixture["tuna"] orig_lettuce = inventory_fixture["lettuce"] orig_onion = inventory_fixture["onion"] orig_tomato = inventory_fixture["tomato"] orig_avocado = inventory_fixture["avocado"] def_wrap1 = order1.Create_Item("Default Wrap") order1.Add_To_Order(def_wrap1) assert(def_wrap1 in order1.Items) #assert(order1.Calculate_Cost() == 8) assert(inventory_fixture["pita"] == (orig_pita - 1)) assert(inventory_fixture["pork"] == (orig_pork - 1)) assert(inventory_fixture["cheese"] == (orig_cheese)) assert(inventory_fixture["tortilla"] == (orig_tortilla)) assert(inventory_fixture["tuna"] == (orig_tuna)) assert(inventory_fixture["lettuce"] == (orig_lettuce - 1)) assert(inventory_fixture["onion"] == (orig_onion)) assert(inventory_fixture["tomato"] == (orig_tomato)) assert(inventory_fixture["avocado"] == (orig_avocado)) assert(order1.ID == None) assert(order1.Status == None)
def test_default_burger(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) orig_white_bun = inventory_fixture["white"] orig_beef = inventory_fixture["beef"] orig_cheese = inventory_fixture["cheese"] orig_tortilla = inventory_fixture["tortilla"] orig_tuna = inventory_fixture["tuna"] orig_lettuce = inventory_fixture["lettuce"] orig_onion = inventory_fixture["onion"] orig_tomato = inventory_fixture["tomato"] orig_avocado = inventory_fixture["avocado"] def_burg1 = order1.Create_Item("Default Burger") order1.Add_To_Order(def_burg1) assert(def_burg1 in order1.Items) assert(order1.Calculate_Cost() == 8) assert(inventory_fixture["white"] == (orig_white_bun - 2)) assert(inventory_fixture["beef"] == (orig_beef - 1)) assert(inventory_fixture["cheese"] == (orig_cheese)) assert(inventory_fixture["tortilla"] == (orig_tortilla)) assert(inventory_fixture["tuna"] == (orig_tuna)) assert(inventory_fixture["lettuce"] == (orig_lettuce - 1)) assert(inventory_fixture["onion"] == (orig_onion)) assert(inventory_fixture["tomato"] == (orig_tomato)) assert(inventory_fixture["avocado"] == (orig_avocado)) assert(order1.ID == None) assert(order1.Status == None)
def test_multiple_items(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) orig_white_bun = inventory_fixture["white"] orig_beef = inventory_fixture["beef"] orig_cheese = inventory_fixture["cheese"] orig_tortilla = inventory_fixture["tortilla"] orig_tuna = inventory_fixture["tuna"] orig_lettuce = inventory_fixture["lettuce"] orig_onion = inventory_fixture["onion"] orig_tomato = inventory_fixture["tomato"] orig_avocado = inventory_fixture["avocado"] burg1 = order1.Create_Item("Burger") burg1.Bun_Type = "white" burg1.Add_Bun() burg1.Add_Bun() burg1.Patty_Type = "beef" burg1.Add_Patty() burg1.Add_Other("cheese") order1.Add_To_Order(burg1) assert(burg1 in order1.Items) assert(order1.Calculate_Cost() == 9) wrap1 = order1.Create_Item("Wrap") wrap1.Wrap_Type = "tortilla" wrap1.Filling_Type = "tuna" wrap1.Add_Other("cheese") wrap1.Add_Other("lettuce") wrap1.Add_Other("onion") wrap1.Add_Other("tomato") wrap1.Add_Other("avocado") order1.Add_To_Order(wrap1) assert(order1.Calculate_Cost() == 38.5) assert(inventory_fixture["white"] == (orig_white_bun - 2)) assert(inventory_fixture["beef"] == (orig_beef - 1)) assert(inventory_fixture["cheese"] == (orig_cheese - 2)) assert(inventory_fixture["tortilla"] == (orig_tortilla - 1)) assert(inventory_fixture["tuna"] == (orig_tuna - 1)) assert(inventory_fixture["lettuce"] == (orig_lettuce - 1)) assert(inventory_fixture["onion"] == (orig_onion - 1)) assert(inventory_fixture["tomato"] == (orig_tomato - 1)) assert(inventory_fixture["avocado"] == (orig_avocado - 1))
def test_add_invalid_order(inventory_fixture, ingredient_cost_fixture): order1 = Order(inventory_fixture, ingredient_cost_fixture) assert(isinstance(order1, Order)) burg1 = order1.Create_Item("Burger") try: order1.Add_To_Order(burg1) except ItemError as err: assert(err.message == "Invalid number of buns selected.") else: assert(False)