Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

92 lines (85 sloc) 3.886 kb
import datetime
import random
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from models import *
class GenerateTestingData(webapp.RequestHandler):
def get(self):
HOW_MANY = 5
for i in range(HOW_MANY):
account = users.User('test%d@example.com' % i)
user = User()
user.who = account
user.first_name = random.choice(['Hubert', 'Margerie', 'Neil', 'Patrick',
'John', 'Matthew', 'Caleb', 'Johan', 'Tricky Dick', 'Robert'])
user.last_name = random.choice(['Cumberdale', 'Stewart-Baxter', 'Harris',
'Tweed', 'Smith', 'Kaney', 'Eggensperger', 'Kaneyburger',
'de Ruiter'])
box = RecipeBox()
box.owner = account
recipes = []
for j in range(HOW_MANY * 2):
recipe = Recipe()
recipe.owner = account
recipe.name = ' '.join([random.choice(['Succulent', 'Divine', 'Rainbow',
'Supreme', 'Buttery', 'Sweet', 'Savory', 'Soapy', 'Impressive',
'Boring', 'Avant-garde', 'Deconstructed', 'Feminist', 'Dry', 'Wet',
'Moist', 'Liberal', 'Conservative', 'Wholesome', 'Homemade',
'Post-structuralist']),
random.choice(['Lemon Tart', 'Banana Surprise', 'Alkaline Battery',
'Pot Roast', 'Pizza', 'Pasta', 'Penne', 'Fruit Leather',
'Vegetable Tray', 'Ice-cream bars', 'Ice-cream', 'Deodorant',
'Dragonmeat', 'Egg Paste', 'Paste', 'Checkbook', 'Novel',
'Boy Band'])])
for k in range(random.randint(HOW_MANY, HOW_MANY * 3)):
item = Item()
item.owner = account
item.name = random.choice(['Butter', 'Cherry', 'Egg', 'Orange',
'Olive', 'Pimento', 'iPhone', 'Cow', 'Slab of meat', 'Tofu',
'Milk', 'Flour', 'Bread', 'Soap', 'Paper', 'Cheese', 'Jack Cheese',
'Battery Acid', 'Pizza', 'Bagel', 'Sage', 'Rosemary', 'Thyme',
'Parsley', 'Duck', 'Croutons', 'Ranch Dressing'])
item.put()
ingredient = Ingredient()
ingredient.item = item
ingredient.amount = random.randint(1, 20)
ingredient.unit = random.choice(['tbsp', 'tsp', 'pinch', '', 'quart'])
ingredient.put()
recipe.ingredients.append(ingredient.key())
for instruction in random.sample(['Cook until brown', 'Cool until blue',
'Cook until tired', 'Cook until cooked', 'Mix all ingredients',
'Stir until your arm hurts', 'Stir for five minutes',
'Preset oven to 400F', 'Place into oven', 'Pour into baking sheet',
'Discard extras', 'Refrigerate for 15 hours', 'Cook for %d minutes' %
random.randint(5, 50), 'Slather with butter',
'Slather with third ingredient', 'Blend in a BlendTec Blender',
'Beat until dead'], random.randint(HOW_MANY, HOW_MANY * 2)):
instruction = Instruction(body=instruction)
instruction.put()
recipe.instructions.append(instruction.key())
recipe.category = 'Other'
recipe.makesserves = bool(random.randint(0,1))
recipe.number = random.randint(1, 60)
recipe.what = 'loaves'
recipe.source = 'The Frugal Gourmand'
recipe.put()
box.contents.append(recipe.key())
for j in range(HOW_MANY):
menu = Menu()
menu.owner = account
menu.what = random.sample(box.contents, random.randint(1,3))
menu.meal = random.randint(0,5)
menu.when = (datetime.date.today() +
datetime.timedelta(random.randint(1,7)))
menu.put()
box.put()
user.box = box
user.put()
self.redirect('/')
application = webapp.WSGIApplication([('/generate', GenerateTestingData),],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
Jump to Line
Something went wrong with that request. Please try again.