Exemple #1
0
 def test_cocktail_init_2(self):
     """Test __init__ method for the class Cocktail"""
     cocktail = Cocktail(None, None, None)
     self.assertEqual(None, cocktail.name)
     self.assertEqual(None, cocktail.glass)
     self.assertEqual(None, cocktail.recipe)
     self.assertEqual(None, cocktail.image)
Exemple #2
0
def load_pickled_data():
  with open('cocktails.pkl', 'rb') as f:
    pickled_cocktails = pickle.load(f)

  for c in pickled_cocktails:
    # instantiate and add cocktail
    cocktail = Cocktail(name=c.name, glass=c.glass, recipe=c.recipe, image=c.image)
    db_session.add(cocktail)

    # add each ingredient that is not already in db
    for i in c.ingredients:
        ingredient = Ingredient.query.filter(Ingredient.name==i[0]).one_or_none()
        if ingredient is None:
            image_name = i[0].replace(' ', '+').replace('/', '\\')
            image_path = '{0}/{1}'.format('ingredients', image_name)

            ingredient = Ingredient(i[0], image_path)

        db_session.add(ingredient)

        # add the amount for each ingredient
        amount = Amount(cocktail, ingredient, i[1])
        db_session.add(amount)
    # commit unpickled cocktail goodness
    db_session.commit()
Exemple #3
0
 def test_amount_repr_1(self):
     """Test __repr__ method for the class Amount"""
     cocktail = Cocktail("Moscow Mule", "Cup", "Moscow Mule Recipe")
     ingredient = Ingredient("Rum")
     amount = Amount(cocktail, ingredient, "2 oz.")
     amount_name = amount.__repr__()
     self.assertEqual(
         "<Amount [%r-|---|-%r]>" % (amount.c_data, amount.i_data),
         amount_name)
Exemple #4
0
 def test_amount_init_3(self):
     """Test __init__ method for the class Amount"""
     cocktail = Cocktail("", "", "")
     ingredient = Ingredient("")
     amount = "3 oz."
     value = Amount(cocktail, ingredient, amount)
     self.assertEqual(cocktail, value.c_data)
     self.assertEqual(ingredient, value.i_data)
     self.assertEqual(amount, value.amount)
Exemple #5
0
 def test_amount_repr_3(self):
     """Test __repr__ method for the class Amount"""
     cocktail = Cocktail("", "", "")
     ingredient = Ingredient("")
     amount = Amount(cocktail, ingredient, "3 oz.")
     amount_name = amount.__repr__()
     self.assertEqual(
         "<Amount [%r-|---|-%r]>" % (amount.c_data, amount.i_data),
         amount_name)
Exemple #6
0
 def test_amount_init_7(self):
     """Test __init__ method for the class Amount"""
     cocktail = Cocktail(None, None, None, None)
     ingredient = Ingredient(None, "static/images/ingredients/Berries.jpg")
     amount = "3 oz."
     value = Amount(cocktail, ingredient, amount)
     self.assertIsNotNone(value.c_data)
     self.assertIsNotNone(value.i_data)
     self.assertIsNotNone(value.amount)
Exemple #7
0
 def test_amount_init_2(self):
     """Test __init__ method for the class Amount"""
     cocktail = Cocktail(None, None, None, None)
     ingredient = Ingredient(None, None)
     amount = "1"
     value = Amount(cocktail, ingredient, amount)
     self.assertEqual(cocktail, value.c_data)
     self.assertEqual(ingredient, value.i_data)
     self.assertEqual(amount, value.amount)
Exemple #8
0
 def test_amount_init_1(self):
     """Test __init__ method for the class Amount"""
     cocktail = Cocktail("Moscow Mule", "Cup", "Moscow Mule Recipe")
     ingredient = Ingredient("Rum")
     amount = "2 oz."
     value = Amount(cocktail, ingredient, amount)
     self.assertEqual(cocktail, value.c_data)
     self.assertEqual(ingredient, value.i_data)
     self.assertEqual(amount, value.amount)
Exemple #9
0
 def test_cocktail_init_7(self):
     """Test __init__ method for the class Cocktail"""
     name = "None"
     glass = "None"
     recipe = "None"
     cocktail = Cocktail(name, glass, recipe)
     self.assertEqual(name, cocktail.name)
     self.assertEqual(glass, cocktail.glass)
     self.assertEqual(recipe, cocktail.recipe)
     self.assertEqual(None, cocktail.image)
Exemple #10
0
 def test_cocktail_init_6(self):
     """Test __init__ method for the class Cocktail"""
     name = None
     glass = None
     recipe = None
     image = "static/images/cocktails/Aqua.jpg"
     cocktail = Cocktail(name, glass, recipe, image)
     self.assertIsNone(cocktail.name)
     self.assertIsNone(cocktail.glass)
     self.assertIsNone(cocktail.recipe)
     self.assertIsNotNone(cocktail.image)
Exemple #11
0
 def test_cocktail_init_5(self):
     """Test __init__ method for the class Cocktail"""
     name = "Aqua"
     glass = "Bottle"
     recipe = "Aqua Recipe"
     image = "static/images/cocktails/Aqua.jpg"
     cocktail = Cocktail(name, glass, recipe, image)
     self.assertEqual(name, cocktail.name)
     self.assertEqual(glass, cocktail.glass)
     self.assertEqual(recipe, cocktail.recipe)
     self.assertIsNotNone(cocktail.image)
Exemple #12
0
 def test_amount_init_5(self):
     """Test __init__ method for the class Amount"""
     cocktail = Cocktail("Aqua", "Bottle", "Aqua Recipe",
                         "static/images/cocktails/Aqua.jpg")
     ingredient = Ingredient("Berries",
                             "static/images/ingredients/Berries.jpg")
     amount = "3 oz."
     value = Amount(cocktail, ingredient, amount)
     self.assertIsNotNone(cocktail, value.c_data)
     self.assertIsNotNone(ingredient, value.i_data)
     self.assertIsNotNone(amount, value.amount)
Exemple #13
0
 def test_amount_repr_4(self):
     """Test __repr__ method for the class Amount"""
     cocktail = Cocktail("Aqua", "Bottle", "Aqua Recipe",
                         "static/images/cocktails/Aqua.jpg")
     ingredient = Ingredient("Berries",
                             "static/images/ingredients/Berries.jpg")
     amount = Amount(cocktail, ingredient, "3 oz.")
     amount_name = amount.__repr__()
     self.assertEqual(
         "<Amount [%r-|---|-%r]>" % (amount.c_data, amount.i_data),
         amount_name)
Exemple #14
0
 def test_cocktail_repr_2(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail(None, None, None, None)
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail None>", drink)
Exemple #15
0
 def test_cocktail_repr_1(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("Vodka Sprite", "Glass", "Vodka Sprite Recipe")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail '%s'>" % cocktail.name, drink)
Exemple #16
0
 def test_cocktail_repr_2(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail(None, None, None, None)
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail None>", drink)
Exemple #17
0
 def test_cocktail_repr_4(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("Aqua", "Bottle", "Aqua Recipe",
                         "static/images/cocktails/Aqua.jpg")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail '%s'>" % cocktail.name, drink)
Exemple #18
0
 def test_cocktail_repr_1(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("Vodka Sprite", "Glass", "Vodka Sprite Recipe")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail '%s'>" % cocktail.name, drink)
Exemple #19
0
 def test_cocktail_repr_3(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("", "", "")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail ''>", drink)
Exemple #20
0
 def test_cocktail_repr_4(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("Aqua", "Bottle", "Aqua Recipe", "static/images/cocktails/Aqua.jpg")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail '%s'>" % cocktail.name, drink)
Exemple #21
0
 def test_cocktail_repr_3(self):
     """Test __repr__ method for the class Cocktail"""
     cocktail = Cocktail("", "", "")
     drink = cocktail.__repr__()
     self.assertEqual("<Cocktail ''>", drink)