コード例 #1
0
def load_recipes(fp):
    """
    Loads in data of the form manufacturer/liquor name/amount from a CSV file.

    Takes a file pointer.

    Adds data to database.

    Returns number of recipes loaded.
    """
    new_reader = data_reader(fp)
    
    x = []
    n = 0
    for curr_rec in new_reader:
        try:
            ingredients = []
            for i in range(1, len(curr_rec), 2):
                try:
                    ingredients.append((curr_rec[i], curr_rec[i+1]))
                except IndexError:
                    print "Check formatting"
            r = recipes.Recipe(curr_rec[0], ingredients)
            db.add_recipe(r)
        except ValueError:
            print "Check usage"
        else:
            n += 1
    return n
コード例 #2
0
ファイル: app.py プロジェクト: alhulaymi/cse491-drinkz
 def add_recipe_script_second(self, environ, start_response):
     formdata = environ['QUERY_STRING']
     results = urlparse.parse_qs(formdata)
     
     no_ing = int(results['no_ing'][0]);
     ingredients = []
     
     for i in range(no_ing):
         drink = results['no_ingredients'+str(i)][0]
         amount = results['amount'+str(i)][0]
         
         ingredients.append((drink,amount))
         
     recipe = recipes.Recipe(results['recipe_name'][0],ingredients)
     
     try:
         db.add_recipe(recipe)
         data = "Added Recipe Successfully"
     except db.DuplicateRecipeName:
         data = "Recipe with name "+ results['recipe_name'][0] +"already exists"
         
     
     script = ""
     data = self.buildHtmlPage("Add Recipe Form 2",script,data)
     start_response('200 OK', list(html_headers))
     return [data]
コード例 #3
0
ファイル: app.py プロジェクト: mmarinetti/Python-Server
    def recv_recipes(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        name = results['name'][0]
        ing1 = results['ing1'][0]
        amount1 = results['amount1'][0]
        try:
            ing2 = results['ing2'][0]
            amount2 = results['amount2'][0]
            r = recipes.Recipe(name, [(ing1, amount1), (ing2, amount2)])
        except KeyError:
            r = recipes.Recipe(name, [(ing1, amount1)])
            ing2, amount2 = "", ""

        db.add_recipe(r)
    
        content_type = 'text/html'
        data = """\
Added recipe.
<p>
"""
        data += "Recipe: %s" % name
        data += "<p>"
        data += "Ingredients: %s %s, %s %s" % (ing1, amount1, ing2, amount2)
        data += """ 
<p>
<a href='./'>return to index</a>
"""

        start_response('200 OK', list(html_headers))
        return [data]
コード例 #4
0
ファイル: app.py プロジェクト: khessiny/cse491-drinkz
    def rpc_addrecipe(self,name,ingridients):
	try:
		name = name.strip()
		ing = ingridients.strip()
		templist = ing.split(',')
		sendoff = []
		counter = 0
		while counter< len(templist):
			temp1 = templist[counter].strip()
			temp2 = templist[counter+1].strip()
			finalamount = str(convert.convert_to_ml(temp2))
			finalamount = finalamount + "ml"
			print temp1,finalamount
			sendoff.append((temp1,finalamount))
			counter = counter + 2
		r = recipes.Recipe(name, sendoff)
		try:
			db.add_recipe(r)
			addin= "Succesfully Added."

		except db.DuplicateRecipeName:
			addin= "There is already a recipe by this name."
	
	except (AssertionError, KeyError, IndexError) :
		addin = "Incorrect format or incomplete. Please try again."

	return addin
コード例 #5
0
ファイル: app.py プロジェクト: dwigell/cse491-drinkz
    def recvRecipe(self, environ, start_response):
        formdata = environ['QUERY_STRING']

        results = urlparse.parse_qs(formdata)

        name = results['name'][0]
        ingredients = results['ingredients'][0]


        ing_list = ingredients.split(',')
        #print ing_list
        ing_tup_list = []

        i = 0
        while i < len(ing_list):
            ingName = ing_list[i]
            ingAmt = ing_list[i+1]
            tempTup = (ingName, ingAmt)
            ing_tup_list.append(tempTup)
            i+=2

        #print ing_tup_list
        r = recipes.Recipe(name, ing_tup_list)
        db.add_recipe(r)

        content_type = 'text/html'
        data = "%s <a href='/'>return to index</a>" % "Your recipe has been added"

        start_response('200 OK', list(html_headers))
        return [data]
コード例 #6
0
ファイル: app.py プロジェクト: newrockm/cse491-drinkz
 def do_add_recipe(self, environ):
     error = None
     if environ.get('CONTENT_LENGTH'):
         length = int(environ['CONTENT_LENGTH'])
         body = environ['wsgi.input'].read(length)
         d = urlparse.parse_qs(body)
         if d.has_key('cancel'):
             # nothing submitted, nothing to do
             return error
         try:
             name = d['name'][0]
             ingredients = []
             for num in range(1,6):
                 n = str(num)
                 if not d.has_key('qty' + n):
                     # ingredient not present
                     continue
                 # this will cause a ValueError if qty is not a number
                 qty = float(d['qty' + n][0])
                 # but we don't care about that other than to get the error
                 amount = '%s %s' % (d['qty' + n][0], d['unit' + n][0])
                 typ = d['typ' + n][0]
                 ingredients.append((typ, amount))
             r = Recipe(name, ingredients)
             db.add_recipe(r)
         except (KeyError, ValueError):
             error = "Error processing form."
     return error
コード例 #7
0
ファイル: my_tests.py プロジェクト: benblaut/cse491-drinkz
def test_add_recipe():
    db._reset_db()
    r = recipes.Recipe('vodka martini', [('vodka', '6 oz'), ('vermouth', '1 oz')])
    db.add_recipe(r)

    assert len(db._recipe_db) == 1
    print db._recipe_db
コード例 #8
0
ファイル: app.py プロジェクト: andre223/cse491-drinkz
    def addRecipe(self, environ, start_response):
        formdata = environ["QUERY_STRING"]
        results = urlparse.parse_qs(formdata)

        name = results["name"][0]
        ings = results["ing"][0]
        myList = ings.split(",")
        myIngSet = set()

        i = 0
        while i < len(myList):
            val = (ingred, amount) = (myList[i], myList[i + 1])
            myIngSet.add(val)
            i += 2

        r = recipes.Recipe(name, myIngSet)

        try:
            db.add_recipe(r)
            data = recipesList()
        except Exception:
            data = recipesList()

        content_type = "text/html"
        start_response("200 OK", list(html_headers))
        return [data]
コード例 #9
0
ファイル: test_app.py プロジェクト: alhulaymi/cse491-drinkz
def test_app():
    db._reset_db()
    recipe1 = recipes.Recipe('vodka martini', [('vermouth', '1.5 oz')])

    recipe2 =  recipes.Recipe('vomit inducing martini', [('blended scotch',
                                                          '2 oz'),
                                                         ('unflavored vodka',
                                                          '1.5 oz')])

    db.add_recipe(recipe1)
    db.add_recipe(recipe2)
    
    environ = {}
    environ['PATH_INFO'] = '/recipes'
    
    
    d = {}
    def my_start_response(s, h, return_in=d):
        d['status'] = s
        d['headers'] = h

    app_obj = app.SimpleApp()
    results = app_obj(environ, my_start_response)

    text = "".join(results)
    status, headers = d['status'], d['headers']
    
    assert text.find('vodka martini') != -1, text
    assert text.find('vomit inducing martini') != -1, text
    assert ('Content-type', 'text/html') in headers
    assert status == '200 OK'
コード例 #10
0
def test_rpc_get_recipe_names():
    db._reset_db()
    recipe1 = recipes.Recipe("youth fountain martini", [("vermouth", "1.5 oz"), ("elve tear", "2 oz")])
    recipe2 = recipes.Recipe("godly vodka", [("mermaid tear", "1.5 oz"), ("unicorn blood", "2 oz")])
    db.add_recipe(recipe1)
    db.add_recipe(recipe2)

    method = "get_recipe_names"
    params = []
    id = 1
    environ = {}
    environ["PATH_INFO"] = "/rpc"
    environ["REQUEST_METHOD"] = "POST"
    dic = dict(method=method, params=params, id=id)
    s_input = simplejson.dumps(dic)
    environ["wsgi.input"] = StringIO(s_input)  # looking for a socket? suuuuure, here's "one"
    environ["CONTENT_LENGTH"] = len(s_input)

    d = {}

    def my_start_response(s, h, return_in=d):
        d["status"] = s
        d["headers"] = h

    app_obj = app.SimpleApp()
    results = app_obj(environ, my_start_response)

    text = "".join(results)
    status, headers = d["status"], d["headers"]

    assert text.find("youth fountain martini") != -1, text
    assert text.find("godly vodka") != -1, text

    assert ("Content-Type", "application/json") in headers
    assert status == "200 OK"
コード例 #11
0
def test_rpc_get_recipe_names():
    db._reset_db()
    recipe1 = recipes.Recipe('Equalizer', [('punch', '1 oz'),('Freedom','2 oz')])

    db.add_recipe(recipe1)
    
    method = 'get_recipe_names'
    params = []
    id = 1
    environ = {}
    environ['PATH_INFO'] = '/rpc'
    environ['REQUEST_METHOD'] = ('POST')
    dic = dict(method=method, params=params, id=id)
    s_input = simplejson.dumps(dic)
    environ['wsgi.input'] = StringIO(s_input)    # looking for a socket? suuuuure, here's "one"
    environ['CONTENT_LENGTH'] = len(s_input)
    
    d = {}
    def my_start_response(s, h, return_in=d):
        d['status'] = s
        d['headers'] = h
        
    app_obj = app.SimpleApp()
    results = app_obj(environ, my_start_response)

    text = "".join(results)
    status, headers = d['status'], d['headers']
    
    assert text.find("Equalizer") != -1, text
 
    assert ('Content-Type', 'application/json') in headers
    assert status == '200 OK'
コード例 #12
0
def test_json_recipe_names():
    db._reset_db()

    r = recipes.Recipe('scotch on the rocks', [('blended scotch', '4 oz')])
    db.add_recipe(r)

    results = call_remote(method='get_recipe_names', params=[], id=1)

    assert 'scotch on the rocks' in results['result'], results['result']
コード例 #13
0
ファイル: my_tests.py プロジェクト: benblaut/cse491-drinkz
def test_get_recipe():
    db._reset_db()
    r = recipes.Recipe('vodka martini', [('vodka', '6 oz'), ('vermouth', '1 oz')])
    db.add_recipe(r)
    x = db.get_recipe('vodka martini')
    
    assert r == x
    if(x):
        print x.name, x.ingredients
コード例 #14
0
ファイル: app.py プロジェクト: mill2121/cse491-drinkz
    def rpc_AddRecipe(self, recipeName, ingredients):

        ingredients = ingredients.split(',')
        Ingredients = []
        i = 0
        while i < len(ingredients):
            Ingredients.append((ingredients[i], ingredients[i+1]))
            i+=2

        db.add_recipe(recipes.Recipe(recipeName, Ingredients));
コード例 #15
0
ファイル: app.py プロジェクト: philgetzen/cse491-drinkz
    def rpc_add_recipe(self, name, Ingredients):
        r = recipes.Recipe(name, Ingredients)
        db.add_recipe(r)

        recipeSet = db.get_all_recipes()

        for rec in recipeSet:
            if rec.name == name:
                return True

        return False
コード例 #16
0
ファイル: my_tests.py プロジェクト: benblaut/cse491-drinkz
def test_get_all_recipes():
    db._reset_db()
    r = recipes.Recipe('vodka martini', [('vodka', '6 oz'), ('vermouth', '1 oz')])
    db.add_recipe(r)
    r2 = recipes.Recipe('screwdriver', [('orange juice', '6 oz'), ('vodka', '1 oz')])
    db.add_recipe(r2)
    x = db.get_all_recipes()

    assert len(x) == 2
    for rec in x:
        print rec.name, rec.ingredients
コード例 #17
0
ファイル: app.py プロジェクト: FauxJake/cse491-drinkz
	def rpc_add_recipe(self,**params):
		name = params["name"]
		ingredients = params["ingredients"]
		
		if len(name) > 0 and len(ingredients) > 0:
			try:
				r = recipes.Recipe(name,ingredients)

				db.add_recipe(r)
				return True
			except Exception, e:
				return e.message
コード例 #18
0
ファイル: main.py プロジェクト: goodnessm3/calorie-tracker
    def add_recipe(self):

        nm = self.recipe_name_input.get()
        portions = self.recipe_portion_input.get()
        if not portions:
            self.log("Portion size not entered")
            return
        db.add_recipe(nm, self.inglist, portions)
        self.recipe_name_input.delete(0, END)
        self.recipe_portion_input.delete(0, END)
        self.inglist = []
        self.log(f"Added recipe for {nm} to the database.")
        self.entry_boxes.refresh_autocompletes()
コード例 #19
0
def create_data(filename):
	try:
		db.load_db(filename)
	except Exception:
		db._reset_db()

		db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch')
		db.add_to_inventory('Johnnie Walker', 'black label', '1 gallon')
		db.add_to_inventory('Johnnie Walker', 'black label', '500 ml')

		db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
		db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')

		db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
		db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

		db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
		db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')

		db.add_bottle_type('Jose Cuervo', 'Silver', 'tequila')
		db.add_to_inventory('Jose Cuervo', 'Silver', '1 liter')

		r = recipes.Recipe('scotch on the rocks', [('blended scotch','4 oz')])
		db.add_recipe(r)
		r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'),('vermouth', '1.5 oz')])
		db.add_recipe(r)
		r = recipes.Recipe('vomit inducing martini', [('orange juice','6 oz'),('vermouth','1.5 oz')])
		db.add_recipe(r)
		r = recipes.Recipe('whiskey bath', [('blended scotch', '2 liter')])
		db.add_recipe(r)
コード例 #20
0
ファイル: app.py プロジェクト: newrockm/cse491-drinkz
    def rpc_add_recipe(self, name, *args):
        if len(args) == 0 or len(args) % 2 != 0:
            # no ingredients or incorrect number of parameters
            return 'Error: incorrect number of ingredients'

        ingredients = []
        num = 0
        while num < len(args):
            # type, amount
            ingredients.append((args[num], args[num + 1]))
            num += 2
        r = Recipe(name, ingredients)
        db.add_recipe(r)
        return 'OK'
コード例 #21
0
ファイル: test_app.py プロジェクト: khessiny/cse491-drinkz
def test_webapp():
	#Add recipes
	r = recipes.Recipe('scotch on the rocks', [('blended scotch','4 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'),('vermouth', '1.5 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('vomit inducing martini', [('orange juice','6 oz'),('vermouth','1.5 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('whiskey bath', [('blended scotch', '5.5 liter')])
	db.add_recipe(r)

    	environ = {}
	environ['PATH_INFO'] = '/recipes'
    	d = {}
    	def my_start_response(s, h, return_in=d):
        	d['status'] = s
        	d['headers'] = h

	app_obj = app.SimpleApp()
    	results = app_obj(environ, my_start_response)
    	text = "".join(results)
    	status, headers = d['status'], d['headers']
    	assert text.find('scotch on the rocks') != -1, text
    	assert text.find('vodka martini') != -1, text
    	assert text.find('vomit inducing martini') != -1, text
    	assert text.find('whiskey bath') != -1, text
    	assert ('Content-type', 'text/html') in headers
    	assert status == '200 OK'
コード例 #22
0
ファイル: dynamic_web.py プロジェクト: chuy2412/cse491-drinkz
def add_items():
        #Reset database
        db._reset_db()

	db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch')
	db.add_to_inventory('Johnnie Walker', 'black label', '500 ml')

	db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
	db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')
        
	db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
	db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

	db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
	db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')

	#Add recipes
	r = recipes.Recipe('scotch on the rocks', [('blended scotch','4 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'),('vermouth', '1.5 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('vomit inducing martini', [('orange juice','6 oz'),('vermouth','1.5 oz')])
	db.add_recipe(r)
	r = recipes.Recipe('whiskey bath', [('blended scotch', '2 liter')])
	db.add_recipe(r)
コード例 #23
0
ファイル: test_jsonrpc.py プロジェクト: mbozugrace/HappyHours
    def test_json_recipes():
        r = recipes.Recipe('Shirley Temple', [('Sprite', '50 oz')])
        db.add_recipe(r)

        r = recipes.Recipe('Margarita', [('Tequila', '30 oz')])
        db.add_recipe(r)

        recipes_name = call_remote(server_base, method='getrecipenames', params=[], id=1)

        rpc_request = simplejson.loads(recipes_name)

        print rpc_request

        result = rpc_request['result']

        assert result == ['Shirley Temple', 'Margarita']
コード例 #24
0
ファイル: app.py プロジェクト: AdamPro13/cse491-drinkz
 def rpc_add_recipe(self,name,ings):
     myList = ings.split(',')
     myIngSet = set()
     i = 0
     while i < len(myList):
         
         val = (ingred,amount) = (myList[i],myList[i+1])
         myIngSet.add(val)
         i+=2
     
     r = recipes.Recipe(name,myIngSet)
     try:
         db.add_recipe(r)
         returnVal = True
     except Exception:
         returnVal = False
     return returnVal
コード例 #25
0
ファイル: app.py プロジェクト: zippleer/cse491-drinkz
    def recipe_add(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        ing_list = []

        #ing_num = (results['i_num'][0])
        #print ing_num
        x = 0
        rec_name = (results['r_name'][0])
        truthiness = True
        while(truthiness):
            try:        
                liq_name = (results['r_liq'][x])
                liq_amount = (results['r_amount'][x])
                new_ing = (liq_name, liq_amount)
                ing_list.append(new_ing)
                x = x + 1
            except IndexError:
                truthiness = False
                pass # Got all ingredients


        new_r = recipes.Recipe(rec_name, ing_list)

        db.add_recipe(new_r)

        content_type = 'text/html'

        data = "Recipe entered: %s:" % rec_name
        
        data = data + """</br>
    </br>
    <h2> Menu </h2>
    <a href='/'>Home</a></br>
    <a href='recipes'>Recipes</a></br>
    <a href='inventory'>Inventory</a></br>
    <a href='liquor_types'>Liquor Types</a></br>
    <a href='convert_to_ml'>Convert Amount</a></br>
    <a href='recipe_input'>Add Recipe</a></br>
    <a href='type_form'>Add Bottle Type</a></br>
    <a href='inv_form'>Add to Inventory</a></br>
    """
        data = self.buildHtmlPage("Added, but would you really drink that?","",data)
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #26
0
ファイル: test_jsonrpc.py プロジェクト: Befall/cse491-drinkz
def populate_database():
    db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch')
    db.add_to_inventory('Johnnie Walker', 'black label', '500 ml')

    db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
    db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')

    db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
    db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

    db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
    db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')

    r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'), ('vermouth', '1.5 oz')])
    db.add_recipe(r)
    r = recipes.Recipe('Gin and Tonic', [('gin', '2 oz'), ('tonic water', '5 oz')])
    db.add_recipe(r)
コード例 #27
0
def load_recipe(fp):
    listed_fp = fp.replace('>','<').split('<')
    recipe_list = []
    
    for recipe in listed_fp:
      if not recipe.startswith(' ') and not recipes=='':
	recipe_list.append(recipe)
    recipe_list = filter(None, recipe_list)
    for recipe_ in recipe_list:
      element_list = recipe_.replace('(',')').split(')')
      name = element_list.pop(0)
      list_of_liquor = []
      for element in element_list:
	 if not element.startswith(' ') and element!='':
	   liquor = element.split(',')
	   list_of_liquor.append((liquor[0],liquor[1]))
	   r = recipes.Recipe(name,list_of_liquor)

      db.add_recipe(r)
コード例 #28
0
ファイル: app.py プロジェクト: birdanth/cse491-drinkz
    def recipes_recv(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        name = results['name'][0]
        ingName = results['ingName'][0]
        ingAmount = results['ingAmount'][0]    
        ing = []
        ing.append((ingName, ingAmount))
        rec = name,ing
        r = recipes.Recipe(rec[0],rec[1])
        db.add_recipe(r)       
        content_type = 'text/html'

        #data = 'name: %s  ingName:  %s  ingAmount: %s' % (name , ingName, ingAmount) 
        data1 = " *** Recipe ( %s ,[( %s , %s )] ) added <br><br>" % (name, ingName, ingAmount)
        data2 =  make_html.recipes()
        data = data1 + data2
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #29
0
ファイル: app.py プロジェクト: Chris498/cse491-drinkz
    def recipes_add(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        name = results['name'][0]
        ingredients = results['ingredients'][0]

        ingredients = ingredients.splitlines()
        ingredients = [ x.strip() for x in ingredients ] # clean whitespace
        ingredients = [ x for x in ingredients if x ]    # remove empty
        ingredients = [ x.split(',') for x in ingredients ]

        r = recipes.Recipe(name, ingredients)
        db.add_recipe(r)
        
        headers = list(html_headers)
        headers.append(('Location', '/recipes'))

        start_response('302 Found', headers)
        return ["Redirect to /recipes..."]
コード例 #30
0
ファイル: test_drinkz.py プロジェクト: benblaut/cse491-drinkz
def test_get_mixable_recipes():
    db._reset_db()
    
    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '1000 ml')
    
    db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
    db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')
        
    db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
    db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

    db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
    db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')
    
    db.add_bottle_type('Meijer', 'pulp free orange juice', 'orange juice')
    db.add_to_inventory('Meijer', 'pulp free orange juice', '24 oz')
    
    r = recipes.Recipe('scotch on the rocks', [('blended scotch',
                                                   '4 oz')])
    db.add_recipe(r)
    
    r = recipes.Recipe('vodka gimlit', [('unflavored vodka', '4 oz'), ('lime juice', '1 oz')])
    db.add_recipe(r)
    
    r = recipes.Recipe('vomit inducing martini', [('orange juice',
                                                      '6 oz'),
                                                     ('vermouth',
                                                      '1.5 oz')])
    db.add_recipe(r)
    
    mixable_recs = db.get_mixable_recipes()
    
    for rec in mixable_recs:
        print rec.name
コード例 #31
0
ファイル: test_app.py プロジェクト: FauxJake/cse491-drinkz
def test_recipes():
	#just in case of freak accidents
	db._reset_db()

	#add some test data
	db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch')
	db.add_to_inventory('Johnnie Walker', 'black label', '500 ml')

	db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
	db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')
        
	db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
	db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

	db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
	db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')

	r = recipes.Recipe('scotch on the rocks', [('blended scotch',
                                                   '4 oz')])
	
	db.add_recipe(r)

	#initialize the app
	environ = {}
	environ['PATH_INFO'] = '/recipes_list'

	d = {}
	def my_start_response(s, h, return_in=d):
		d['status'] = s
		d['headers'] = h

	app_obj = app.SimpleApp()
	results = app_obj(environ, my_start_response)

	text = "".join(results)
	status, headers = d['status'], d['headers']
    
	assert text.find('<td>Scotch On The Rocks</td>') != -1, text
	assert ('Content-type', 'text/html') in headers
	assert status == '200 OK'
コード例 #32
0
def recipe_completed():
    recipe = request.args.get('recipe')
    if recipe:
        db.add_recipe(recipe)
    return redirect(url_for('index'))