def db_Init(): 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') db.add_bottle_type('Freedom Walker', 'blue label', 'unblended scotch') 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)
def make_test_db(): db._reset_db() db.add_bottle_type('Kraken', 'dark spiced rum', 'dark spiced rum') db.add_to_inventory('Kraken', 'dark spiced rum', '750 ml') db.add_bottle_type('Bols', 'blue curacao', 'citrus liqeur') db.add_to_inventory('Bols', 'blue curacao', '500 ml') db.add_bottle_type('Hypnotiq', 'original', 'berry liqeur') db.add_to_inventory('Hypnotiq', 'original', '750 ml') db.add_bottle_type('Uncle John\'s', 'original cider', 'apple cider') db.add_to_inventory('Uncle John\'s', 'original cider', '1 g') kraken_destroyer = Recipe('kraken destroyer', [('dark spiced rum', '4.5 oz'), ('citrus liqeur', '1 oz'), ('berry liqeur', '1 oz'), ('apple cider', '8 oz')]) db.add_recipe(kraken_destroyer) kraken_and_cola = Recipe('kraken and cola', [('dark spiced rum', '6 oz'), ('cola', '8 oz')]) db.add_recipe(kraken_and_cola)
def test_recipes(): db._reset_db() db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch') db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter') r = recipes.Recipe('whiskey bath', [('blended scotch', '2 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('Recipes') != -1, text assert text.find('whiskey bath') != -1, text assert ('Content-type', 'text/html') in headers assert status == '200 OK'
def test_add_to_inventory(): db._reset_db() db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch') x = make_rpc_call('add_to_inventory', ('Uncle Herman\'s', 'moonshine', '5 liter')) x = make_rpc_call('get_liquor_inventory', []) assert x == [[u"Uncle Herman's", u'moonshine']]
def test_json_add_recipe(): db._reset_db() db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch') db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter') make_rpc_call('add_recipe', (('whiskey bath', [('blended scotch', '2 liter')]))) x = make_rpc_call('get_recipe_names', []) assert 'whiskey bath' in x
def test_json_inventory(): db._reset_db() db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch') db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter') r = recipes.Recipe('whiskey bath', [('blended scotch', '2 liter')]) db.add_recipe(r) x = make_rpc_call('get_liquor_inventory', []) assert x == [[u"Uncle Herman's", u'moonshine']]
def test_add_bottle_type(): db._reset_db() make_rpc_call('add_bottle_type', ('Uncle Herman\'s', 'moonshine', 'blended scotchX')) # this will fail without the above working. x = make_rpc_call('add_to_inventory', ('Uncle Herman\'s', 'moonshine', '5 liter')) x = make_rpc_call('get_liquor_inventory', []) assert x == [[u"Uncle Herman's", u'moonshine']]
#! /usr/bin/env python import os from drinkz import db, recipes db._reset_db() db.load_db('savedtestdb') if db._check_bottle_type_exists('Johnnie Walker', 'Black Label'): present = 'Black Label' if db._check_bottle_type_exists('Anheuser-Busch', 'Bud Light'): presen = 'Bud Light' r = recipes.Recipe() d = r.need_ingredients() for k in d: print d[k] i = 0 value = db.get_recipe('scotch on the rocks')
import os from drinkz import db, recipes try: os.mkdir('html') except OSError: # already exists pass """ 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_to_inventory('Johnnie Walker', 'black label', '12 oz') 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') scotch_on_the_rocks = recipes.Recipe('scotch on the rocks', [('blended scotch', '4 oz')]) db.add_recipe(scotch_on_the_rocks) martini = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'), ('vermouth', '1.5 oz')])
def main(): db._reset_db() db.load_db("database") ### try: os.mkdir('html') except OSError: # already exists pass ### fp = open('index.html', 'w') print >>fp, """<html> <head> <title>The Lush - A Alcoholic Database.</title> <style type='text/css'> h1 {color:black;} body { font-size: 14px; } </style> <script> function myFunction() { alert("Hello! I am an alert box!"); } </script> </script> <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> </head> <body> """ print >>fp, "<h1>Welcome to The Lush.</h1>" print >>fp, "<p><a href='liquortypes'>Types of Liquor</a> " print >>fp, "<a href='inventory'>Inventory of Booze</a> " print >>fp, "<a href='recipes'>Recipe List</a> " print >>fp, "<a href='form'>Convert-to-ml</a> " print >>fp, "<p><p> This will one day be the ultimate tool for any hardy drinker. Sadly it is still a work in development. <p>Feel free to try out the available tools. <p>Remember you must be signed in to vote on recipes!" fp.close() ### ### fp = open('html/liquor_types.html', 'w') print >>fp, """<html> <head> <title>Liquor Types.</title> <style type='text/css'> h1 {color:black;} body { font-size: 14px; } </style> </script> </head> <body> """ print >>fp, "<h1>Types of Liquor </h1> " print >>fp, "<p><a href='/'>HomePage</a> " print >>fp, "<a href='liquortypes'>Types of Liquor</a> " print >>fp, "<a href='inventory'>Inventory of Booze</a> " print >>fp, "<a href='recipes'>Recipe List</a> " print >>fp, "<p><a href='form_add_type'>Add a New Type</a> " print >>fp, '<script type="text/javascript"src="jquery-1.2.6.min.js"></script><script type="text/javascript" src="jquery.form.js"></script><script type="text/javascript" src="application.js"></script>' print >>fp, "<b><p>Liquor<p></b>" ### ### fp = open('html/inventory.html', 'w') print >>fp, """<html> <head> <title>Inventory Page.</title> <style type='text/css'> h1 {color:black;} body { font-size: 14px; } </style> </script> </head> <body> """ print >>fp, "<h1>Current Inventory </h1> " print >>fp, "<p><a href='/'>HomePage</a> " print >>fp, "<a href='liquortypes'>Types of Liquor</a> " print >>fp, "<a href='inventory'>Inventory of Booze</a> " print >>fp, "<a href='recipes'>Recipe List</a> " print >>fp, "<p><a href='form_add_inv'>Add a New Inventory</a> " print >>fp, "<b><p>Name : Liquor : Amount in ml<p></b>" fp.close() ### ### fp = open('html/recipes.html', 'w') print >>fp, """<html> <head> <title>Recipe List.</title> <style type='text/css'> h1 {color:black;} body { font-size: 14px; } </style> </script> </head> <body> """ print >>fp, "<h1>Recipes </h1> " print >>fp, "<p><a href='/'>HomePage</a> " print >>fp, "<a href='liquortypes'>Types of Liquor</a> " print >>fp, "<a href='inventory'>Inventory of Booze</a> " print >>fp, "<a href='recipes'>Recipe List</a> " print >>fp, "<p><a href='form_add_recipe'>Add a New Recipe</a> " print >>fp, "<p>If you are logged in voting forms will appear next to each recipe. <p> Feel free to throw in your opinion and help decide what recipe is forever the best. <p> Scores are from 1-5 " print >>fp, "<b><p>Score : Name : Ingredients<p></b>" fp.close() ### return 0
os.mkdir("html") except OSError: # already exists pass try: os.mkdir("html/subdir") except OSError: # already exists pass ######################################################################## # Add items to the inventory # Copied the drinks from drinkz/test_recipes.py ######################################################################## db._reset_db() # Reset 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") # Add recipes r = recipes.Recipe("scotch on the rocks", [("blended scotch", "4 oz")])