Example #1
0
 def put(self, ingredient_name, mixing_bowl_id=None, lineno=None):
     'This puts the ingredient into the nth mixing bowl.'
     try:
         mixing_bowl = self.get_nth_container(mixing_bowl_id, lineno)
     except NonExistingContainerError:
         # create a new mixing bowl if the ID is larger than the current
         # largest mixing bowl ID by 1
         if mixing_bowl_id - 1 == len(self.mixing_bowls):
             mixing_bowl = Ingredients()
             self.mixing_bowls.append(mixing_bowl)
         else:
             raise InvalidContainerIDError(
                 'mixing bowl', mixing_bowl_id, lineno)
     ingredient = self.get_ingredient_by_name(ingredient_name, lineno)
     mixing_bowl.append(ingredient)
Example #2
0
 def setup_method(self, method):
     self.ingredients = Ingredients([
         Ingredient('first', IngredientProperties(1, True, False)),
         Ingredient('second', IngredientProperties(2, True, False)),
         Ingredient('third', IngredientProperties(3, True, False)),
         Ingredient('fourth', IngredientProperties(4, True, False)),
         Ingredient('fifth', IngredientProperties(5, True, False))])
Example #3
0
class TestIngredientsStir(object):
    def setup_method(self, method):
        self.ingredients = Ingredients([
            Ingredient('first', IngredientProperties(1, True, False)),
            Ingredient('second', IngredientProperties(2, True, False)),
            Ingredient('third', IngredientProperties(3, True, False)),
            Ingredient('fourth', IngredientProperties(4, True, False)),
            Ingredient('fifth', IngredientProperties(5, True, False))])

    def test_one(self):
        self.ingredients.stir(1)
        assert self.ingredients == Ingredients([
            Ingredient('first', IngredientProperties(1, True, False)),
            Ingredient('second', IngredientProperties(2, True, False)),
            Ingredient('third', IngredientProperties(3, True, False)),
            Ingredient('fifth', IngredientProperties(5, True, False)),
            Ingredient('fourth', IngredientProperties(4, True, False))])

    def test_three(self):
        self.ingredients.stir(3)
        assert self.ingredients == Ingredients([
            Ingredient('first', IngredientProperties(1, True, False)),
            Ingredient('fifth', IngredientProperties(5, True, False)),
            Ingredient('second', IngredientProperties(2, True, False)),
            Ingredient('third', IngredientProperties(3, True, False)),
            Ingredient('fourth', IngredientProperties(4, True, False))])

    def test_no_modification(self):
        self.ingredients.stir(0)
        assert self.ingredients == Ingredients([
            Ingredient('first', IngredientProperties(1, True, False)),
            Ingredient('second', IngredientProperties(2, True, False)),
            Ingredient('third', IngredientProperties(3, True, False)),
            Ingredient('fourth', IngredientProperties(4, True, False)),
            Ingredient('fifth', IngredientProperties(5, True, False))])

    def test_too_damn_high(self):
        self.ingredients.stir(5)
        assert self.ingredients == Ingredients([
            Ingredient('fifth', IngredientProperties(5, True, False)),
            Ingredient('first', IngredientProperties(1, True, False)),
            Ingredient('second', IngredientProperties(2, True, False)),
            Ingredient('third', IngredientProperties(3, True, False)),
            Ingredient('fourth', IngredientProperties(4, True, False))])