예제 #1
0
def test_multiple_orders(system):

    system.new_order(system.generate_id())

    drink1 = Drink("Fanta can")
    drink2 = Drink("Water bottle")

    system.add_to_order(drink1, 1)
    system.add_to_order(drink2, 1)

    side1 = Side("Small fries")
    side2 = Side("Cookie")

    system.add_to_order(side1, 2)
    system.add_to_order(side2, 2)

    assert (system.get_order(1).get_status() == False)
    assert (system.get_order(1).get_confirmed() == False)
    assert (len(system.get_order(1).get_order_list()) == 2)
    assert (system.get_order(1).total_price() == 6)

    assert (system.get_order(2).get_status() == False)
    assert (system.get_order(2).get_confirmed() == False)
    assert (len(system.get_order(2).get_order_list()) == 2)
    assert (system.get_order(2).total_price() == 4.5)

    assert (len(system.get_orders()) == 2)
    def welcomeInterface(self, pantry):
        print("========================================")
        print("Create an order with GourmetBurgers.com!")

        while True:
            print("========================================")
            print("Type 1 to add a main.")
            print("Type 2 to add a side.")
            print("Type 3 to review your order.")
            print("Type 4 to confirm order.")
            print("Type C to cancel your order.")
            print("========================================")
            command = input("What would you like to do? ")

            if command.upper() == "C":
                self.status = orderStatus.CANCELED
                break
            elif command.isdigit() == True:
                if int(command) == 1:
                    newMain = Main()  #GLORIA ADD MAINS LOGIC
                    newMain.mainInterface(pantry)
                    if newMain._totalMainPrice != 0.0:
                        self.addOrderMain(newMain)

                elif int(command) == 2:
                    newSide = Side()
                    newSide.sideInterface(pantry)
                    if newSide.side != None:
                        self.addOrderSides(newSide)
                elif int(command) == 3:
                    self.printEntireOrder()
                elif int(command) == 4:
                    self.confirmOrder()
                    if self.status == orderStatus.CONFIRMED:
                        break
예제 #3
0
def test_multiple_items(system):

    side1 = Side("Small fries")
    side2 = Side("Cookie")

    burger = SingleBurger()
    burger.add_ingredient("Sesame bun", 1)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 1)

    wrap = Wrap()
    wrap.add_ingredient("Chicken patty", 1)
    wrap.add_ingredient("Cheddar cheese", 3)
    wrap.add_ingredient("Aioli sauce", 1)

    drink1 = Drink("Fanta can")
    drink2 = Drink("Water bottle")

    system.add_to_order(drink1, 1)
    system.add_to_order(drink2, 1)
    system.add_to_order(wrap, 1)
    system.add_to_order(burger, 1)
    system.add_to_order(side1, 1)
    system.add_to_order(side2, 1)

    assert (len(system.get_orders()) == 1)
    assert (system.get_order(1).get_status() == False)
    assert (system.get_order(1).get_confirmed() == False)
    assert (len(system.get_order(1).get_order_list()) == 6)

    assert (system.get_order(1).total_price() == 21.2)
예제 #4
0
def system_fixture():
    system = System()

    order = system.new_order(system.generate_id())
    burger = SingleBurger()
    burger.add_ingredient("Sesame bun", 1)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 1)

    order.add_item(burger)
    order.add_item(Drink("Water bottle"))
    order.add_item(Side("Small fries"))
    order.add_item(Side("Nuggets 3P"))

    order2 = system.new_order(system.generate_id())
    burger2 = SingleBurger()
    burger2.add_ingredient("Sesame bun", 1)
    burger2.add_ingredient("Muffin bun", 1)
    burger2.add_ingredient("Beef patty", 1)

    order2.add_item(burger)
    order2.add_item(Drink("Coke Can"))
    order2.add_item(Side("Medium fries"))
    order2.add_item(Side("Nuggets 6P"))

    return system
예제 #5
0
def system_fixture():
    system = System()

    ID = system.generate_id()
    assert (ID == 1)
    system.new_order(ID)

    burger = SingleBurger()
    burger.add_ingredient("Sesame bun", 1)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 1)
    burger.add_ingredient("Lettuce", 3)
    burger.add_ingredient("Tomatoes", 2)
    system.add_to_order(burger, ID)
    system.add_to_order(Drink('Water bottle'), ID)
    system.add_to_order(Side("Cookie"), ID)

    assert (system.get_order(ID).total_price() == 13.5)
    success, ID = system.confirm_order(system.get_order(ID))
    assert (success == True)
    assert (ID == 1)
    system.update_status(1)

    ID = system.generate_id()
    assert (ID == 2)
    system.new_order(ID)

    burger = DoubleBurger()
    burger.add_ingredient("Sesame bun", 2)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 2)
    burger.add_ingredient("Lettuce", 3)
    burger.add_ingredient("Tomatoes", 2)
    burger.add_ingredient("BBQ sauce", 2)
    system.add_to_order(burger, ID)

    system.add_to_order(Drink('Coke can'), ID)
    system.add_to_order(Side("Medium fries"), ID)

    assert (system.get_order(ID).total_price() == 17.4)
    success, ID = system.confirm_order(system.get_order(ID))
    assert (success == True)
    assert (ID == 2)

    ID = system.generate_id()
    assert (ID == 3)
    system.new_order(ID)
    for i in range(5):
        system.add_to_order(Drink("Coke can"), ID)
        system.add_to_order(Side("Cookie"), ID)

    assert (system.get_order(ID).total_price() == 20)
    success, ID = system.confirm_order(system.get_order(ID))
    assert (success == True)
    assert (ID == 3)
    system.update_status(3)

    return system
예제 #6
0
def system_fixture():
    system = System()

    ID = system.generate_id()
    assert (ID == 1)
    system.new_order(ID)

    burger = SingleBurger()
    burger.add_ingredient("Sesame bun", 1)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 1)
    burger.add_ingredient("Lettuce", 3)
    burger.add_ingredient("Tomatoes", 2)
    system.add_to_order(burger, ID)
    system.add_to_order(Drink('Water bottle'), ID)
    system.add_to_order(Side("Cookie"), ID)

    assert (system.get_order(ID).total_price() == 13.5)

    ID = system.generate_id()
    assert (ID == 2)
    system.new_order(ID)

    burger = DoubleBurger()
    burger.add_ingredient("Sesame bun", 2)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 2)
    burger.add_ingredient("Lettuce", 3)
    burger.add_ingredient("Tomatoes", 2)
    burger.add_ingredient("BBQ sauce", 2)
    system.add_to_order(burger, ID)

    system.add_to_order(Drink('Coke can'), ID)
    system.add_to_order(Side("Medium fries"), ID)

    assert (system.get_order(ID).total_price() == 17.4)

    ID = system.generate_id()
    assert (ID == 3)
    system.new_order(ID)
    for i in range(20):
        system.add_to_order(Drink("Coke can"), ID)
        system.add_to_order(Side("Cookie"), ID)

    ID = system.generate_id()
    assert (ID == 4)
    system.new_order(ID)

    wrap = Wrap()
    wrap.add_ingredient("Chicken patty", 1)
    wrap.add_ingredient("Cheddar cheese", 3)
    wrap.add_ingredient("Aioli sauce", 1)
    system.add_to_order(wrap, ID)

    assert (system.get_order(ID).total_price() == 5.7)

    return system
 def setup_method(self):
     self.newSystem = onlineOrderSystem()
     ingred1 = self.newSystem.pantry.createNewIngredient("Buns",1,100)
     ingred2 = self.newSystem.pantry.createNewIngredient("Beef Patty",1,100)
     ingred3 = self.newSystem.pantry.createNewIngredient("1L Coke",4,20)
     self.newSystem.pantry.addMainIngredient(ingred1)
     self.newSystem.pantry.addMainIngredient(ingred2)
     self.newSystem.pantry.addSideIngredient(ingred3)
     self.newOrder = Order()
     self.newMain = Main()
     self.newSide = Side()
def sides():
    allSides = GourmetBurgers.pantry.sideIngredients
    if request.method == "POST":
        for dictIterKeys, dictIterValues in request.form.items():
            if dictIterValues.isdigit() == True:
                if int(dictIterValues) > 0:
                    if GourmetBurgers.pantry.getSide(
                            dictIterKeys, -int(dictIterValues)) == True:
                        newSide = Side()
                        newSide.confirmSide(
                            GourmetBurgers.pantry.findSide(dictIterKeys),
                            int(dictIterValues))
                        newOrder.addOrderSides(newSide)
                        print(newSide)
    return render_template("sides.html", allSides=allSides)
 def setup_method(self):
     self.GourmetBurgers = onlineOrderSystem()
     self.newOrder1 = Order()
     self.newOrder1.orderID = self.GourmetBurgers.generateID()
     self.newOrder2 = Order()
     self.newOrder2.orderID = self.GourmetBurgers.generateID()
     self.newOrder3 = Order()
     self.newOrder3.orderID = self.GourmetBurgers.generateID()
     self.newOrder4 = Order()
     self.newOrder4.orderID = self.GourmetBurgers.generateID()
     self.randomSide1 = Side()
     self.randomSide1._quantity = 1
     self.newOrder1.addOrderSides(self.randomSide1)
     self.randomSide2 = Side()
     self.randomSide2._quantity = 2
     self.newOrder2.addOrderSides(self.randomSide2)
예제 #10
0
    def get_sidelist(self):
        eg_side = Side("Small fries")
        sidelist = []

        for key,value in eg_side._side_prices.items():
            sidelist.append(key)
        return sidelist
예제 #11
0
def test_adding_first_order():
    system = System()
    assert(len(system.get_orders()) == 0)
    assert(len(system.get_completed()) == 0)
    order = system.new_order(system.generate_id())
    burger = SingleBurger()
    burger.add_ingredient("Sesame bun", 1)
    burger.add_ingredient("Muffin bun", 1)
    burger.add_ingredient("Beef patty", 1)
    order.add_item(burger)
    order.add_item(Drink("Water bottle"))
    order.add_item(Side("Small fries"))
    order.add_item(Side("Nuggets 3P"))
    success,orderID = system.confirm_order(order)
    assert(success == True)
    assert(orderID == 1)
    assert(len(system.get_orders()) == 1)
    assert(len(system.get_completed()) == 0)
예제 #12
0
def test_successful_sides(system):
    side1 = Side("Small fries")
    side2 = Side("Cookie")

    system.add_to_order(side1, 1)
    system.add_to_order(side2, 1)

    assert (side1.get_price() == 2.5)
    assert (side1.get_name() == "Small fries")
    assert (side2.get_price() == 2)
    assert (side2.get_name() == "Cookie")

    assert (len(system.get_orders()) == 1)
    assert (system.get_order(1).get_status() == False)
    assert (system.get_order(1).get_confirmed() == False)
    assert (len(system.get_order(1).get_order_list()) == 2)

    assert (system.get_order(1).total_price() == 4.5)
 def setup_method(self):
     self.GourmetBurgers = onlineOrderSystem()
     #ingred1 = self.GourmetBurgers.pantry.createNewIngredient("1L Coke",4,20)
     #self.GourmetBurgers.pantry.addSideIngredient(ingred1)
     self.newOrder = Order()
     self.newSide = Side()
예제 #14
0
class TestOrderSystem():
    def setup_method(self):
        self.newSystem = onlineOrderSystem()
        ingred1 = self.newSystem.pantry.createNewIngredient("Buns", 1, 100)
        ingred2 = self.newSystem.pantry.createNewIngredient(
            "Beef Patty", 1, 100)
        ingred3 = self.newSystem.pantry.createNewIngredient("1L Coke", 4, 20)
        self.newSystem.pantry.addMainIngredient(ingred1)
        self.newSystem.pantry.addMainIngredient(ingred2)
        self.newSystem.pantry.addSideIngredient(ingred3)
        self.newOrder = Order()
        self.newMain = Main()
        self.newSide = Side()

    def test_correctlyInitialisedOrder(self):
        assert (self.newOrder._netOrderPrice == 0.0)
        assert (self.newOrder._orderID == None)
        assert (self.newOrder._status == None)
        assert (len(self.newOrder._orderMains) == 0)
        assert (len(self.newOrder._orderSides) == 0)

    def test_addMainsToOrder(self):
        assert (self.newMain._totalMainPrice == 0)
        self.newMain.createBaseBurger(self.newSystem.pantry)
        assert (self.newMain._totalMainPrice == 3)
        assert (len(self.newOrder.orderMains) == 0)
        assert (self.newOrder.netOrderPrice == 0.0)
        self.newOrder.addOrderMain(self.newMain)
        assert (len(self.newOrder.orderMains) == 1)
        assert (self.newOrder.netOrderPrice == 3.0)

    def test_addSidesToOrder(self):
        assert (self.newSide.netSidePrice == 0)
        side = self.newSystem.pantry.findSide("1L Coke")
        assert (side != None)
        self.newSide.confirmSide(side, 2)
        assert (self.newSide._netSidePrice == 8)
        assert (len(self.newOrder.orderSides) == 0)
        assert (self.newOrder.netOrderPrice == 0.0)
        self.newOrder.addOrderSides(self.newSide)
        assert (len(self.newOrder.orderSides) == 1)
        assert (self.newOrder.netOrderPrice == 8.0)

    def test_AddOrderToActiveList(self):
        self.newMain.createBaseBurger(self.newSystem.pantry)
        self.newOrder.addOrderMain(self.newMain)
        self.newOrder.confirmOrderDefault()
        self.newOrder.orderID = self.newSystem.generateID()
        assert (len(self.newSystem.activeOrders) == 0)
        self.newSystem.addActiveOrder(self.newOrder)
        assert (len(self.newSystem.activeOrders) == 1)

    def test_searchForOrders(self):
        self.newMain.createBaseBurger(self.newSystem.pantry)
        self.newOrder.addOrderMain(self.newMain)
        self.newOrder.confirmOrderDefault()
        self.newOrder.orderID = self.newSystem.generateID()
        self.newSystem.addActiveOrder(self.newOrder)
        assert (len(self.newSystem.activeOrders) == 1)
        assert (self.newSystem.getActiveOrder(1) != None)

    def test_searchForNonExistantOrders(self):
        assert (self.newSystem.getActiveOrder(1) == None)
        assert (self.newSystem.getCompletedOrders(1) == None)

    def test_moveOrderActiveToCompleted(self):
        self.newMain.createBaseBurger(self.newSystem.pantry)
        self.newOrder.addOrderMain(self.newMain)
        self.newOrder.confirmOrderDefault()
        self.newOrder.orderID = self.newSystem.generateID()
        self.newSystem.addActiveOrder(self.newOrder)
        assert (len(self.newSystem.activeOrders) == 1)
        assert (self.newSystem.getActiveOrder(1) != None)
        assert (len(self.newSystem.completedOrders) == 0)
        assert (self.newSystem.getCompletedOrders(1) == None)

        self.newSystem.moveToCompleted(1)
        assert (len(self.newSystem.activeOrders) == 0)
        assert (self.newSystem.getActiveOrder(1) == None)
        assert (len(self.newSystem.completedOrders) == 1)
        assert (self.newSystem.getCompletedOrders(1) != None)