class TestMakeComplexBurger():
    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("Cheese",0.5,100)
        ingred4 = self.newSystem.pantry.createNewIngredient("Lettuce",0.5,100)
        self.newSystem.pantry.addMainIngredient(ingred1)
        self.newSystem.pantry.addMainIngredient(ingred2)
        self.newSystem.pantry.addMainIngredient(ingred3)
        self.newSystem.pantry.addMainIngredient(ingred4)
        self.newMain = Main()

    def test_checkStoredInMainIngredients(self):
        assert(len(self.newSystem.pantry.mainIngredients) == 4)

    def test_createBurgerWithExtras(self):
        assert(self.newMain.createBaseBurger(self.newSystem.pantry) == True)
        assert(len(self.newMain.baseIngredients) == 2)
        assert(self.newMain.netMainPrice == 3)
        assert(len(self.newMain.extraIngredients) == 0)
        assert(self.newSystem.pantry.findMain("Buns").quantity == 98)
        assert(self.newSystem.pantry.findMain("Beef Patty").quantity == 99)

        assert(self.newMain.addExtraIngredientBasic(self.newSystem.pantry,"Cheese",2)==True)
        assert(len(self.newMain.extraIngredients) == 1)
        assert(self.newSystem.pantry.findMain("Cheese").quantity == 98)
        assert(self.newMain.netMainPrice == 4)

        assert(self.newMain.addExtraIngredientBasic(self.newSystem.pantry,"Lettuce",1)==True)
        assert(len(self.newMain.extraIngredients) == 2)
        assert(self.newSystem.pantry.findMain("Lettuce").quantity == 99)
        assert(self.newMain.netMainPrice == 4.5)

    def test_cannotAddExtraInsufficientStock(self):
        assert(self.newMain.createBaseBurger(self.newSystem.pantry) == True)
        assert(len(self.newMain.baseIngredients) == 2)
        assert(self.newMain.netMainPrice == 3)
        assert(len(self.newMain.extraIngredients) == 0)
        assert(self.newSystem.pantry.findMain("Buns").quantity == 98)
        assert(self.newSystem.pantry.findMain("Beef Patty").quantity == 99)

        assert(self.newMain.addExtraIngredientBasic(self.newSystem.pantry,"Cheese",200)==False)
        assert(len(self.newMain.extraIngredients) == 0)
        assert(self.newSystem.pantry.findMain("Cheese").quantity == 100)
        assert(self.newMain.netMainPrice == 3)

    def test_cannotAddNonExistingIngredients(self):
        assert(self.newMain.createBaseBurger(self.newSystem.pantry) == True)
        assert(len(self.newMain.baseIngredients) == 2)
        assert(self.newMain.netMainPrice == 3)
        assert(len(self.newMain.extraIngredients) == 0)
        assert(self.newSystem.pantry.findMain("Buns").quantity == 98)
        assert(self.newSystem.pantry.findMain("Beef Patty").quantity == 99)

        assert(self.newMain.addExtraIngredientBasic(self.newSystem.pantry,"Eggs",200)==False)
        assert(len(self.newMain.extraIngredients) == 0)
        assert(self.newMain.netMainPrice == 3)
Example #2
0
class TestMakeComplexWrap():
    def setup_method(self):
        self.newSystem = onlineOrderSystem()
        ingred1 = self.newSystem.pantry.createNewIngredient(
            "Tortillas", 1, 100)
        ingred2 = self.newSystem.pantry.createNewIngredient(
            "Chicken", 1.5, 100)
        ingred3 = self.newSystem.pantry.createNewIngredient("Onions", 0.1, 100)
        ingred4 = self.newSystem.pantry.createNewIngredient("Hommus", 2.5, 30)
        self.newSystem.pantry.addMainIngredient(ingred1)
        self.newSystem.pantry.addMainIngredient(ingred2)
        self.newSystem.pantry.addMainIngredient(ingred3)
        self.newSystem.pantry.addMainIngredient(ingred4)
        self.newMain = Main()

    def test_checkStoredInMainIngredients(self):
        assert (len(self.newSystem.pantry.mainIngredients) == 4)

    def test_createWrapWithExtras(self):
        assert (self.newMain.createBaseWrap(self.newSystem.pantry) == True)
        assert (len(self.newMain.baseIngredients) == 2)
        assert (self.newMain.netMainPrice == 2.5)
        assert (len(self.newMain.extraIngredients) == 0)
        assert (self.newSystem.pantry.findMain("Tortillas").quantity == 99)
        assert (self.newSystem.pantry.findMain("Chicken").quantity == 99)

        assert (self.newMain.addExtraIngredientBasic(self.newSystem.pantry,
                                                     "Onions", 10) == True)
        assert (len(self.newMain.extraIngredients) == 1)
        assert (self.newSystem.pantry.findMain("Onions").quantity == 90)
        assert (self.newMain.netMainPrice == 3.5)

        assert (self.newMain.addExtraIngredientBasic(self.newSystem.pantry,
                                                     "Hommus", 1) == True)
        assert (len(self.newMain.extraIngredients) == 2)
        assert (self.newSystem.pantry.findMain("Hommus").quantity == 29)
        assert (self.newMain.netMainPrice == 6)

    def test_cannotAddExtraInsufficientStock(self):
        assert (self.newMain.createBaseWrap(self.newSystem.pantry) == True)
        assert (len(self.newMain.baseIngredients) == 2)
        assert (self.newMain.netMainPrice == 2.5)
        assert (len(self.newMain.extraIngredients) == 0)
        assert (self.newSystem.pantry.findMain("Tortillas").quantity == 99)
        assert (self.newSystem.pantry.findMain("Chicken").quantity == 99)

        assert (self.newMain.addExtraIngredientBasic(self.newSystem.pantry,
                                                     "Hommus", 200) == False)
        assert (len(self.newMain.extraIngredients) == 0)
        assert (self.newSystem.pantry.findMain("Hommus").quantity == 30)
        assert (self.newMain.netMainPrice == 2.5)