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)
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)
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 )
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 )
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 )
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)
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()
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)
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)
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)
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)
def save_transcation(request): ''' Method for saving Transcation ''' if request.method == "POST": amount=request.POST["amount"] date=request.POST["date_pick"] description=request.POST['desc'] expense=request.POST['expense_value'] expense_obj=Expense.objects.filter(name=expense) expense_id=expense_obj[0].id amount_obj = Amount(amount_value=amount, transcation_date=date, description=description, expense_id=expense_id) amount_obj.save() return render_to_response("add_transcation.html", {"transcation_save_ack":"Saved your Transcation"})
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)