def createTestHacker(number): shirts = ["XS", "S", "M", "L", "XL", "XXL"] def prob(): return random.uniform(0.0, 10.0) hacker = Hacker() hacker.name = "Hacker {0}".format(number) hacker.school = "Brown University" if prob() < 3 else "Another University" hacker.year = "freshman" if prob() < 3: hacker.year = "sophomore" elif prob() < 3: hacker.year = "junior" elif prob() < 3: hacker.year = "senior" hacker.email = "hacker_{0}@{1}.edu".format(number, hacker.school.lower().split(" ")[0]) hacker.secret = generate_secret_for_hacker_with_email(hacker.email) hacker.shirt_gen = "M" if prob() < 5 else "W" hacker.shirt_size = random.choice(shirts) rawDiet = [ "Vegetarian", "Vegan", "Gluten Free", "Kosher", "Lactose Intolerant", "Nuts Allergy", "Treenuts Allergy", "Soy Allergy", "Shellfish Allergy", "Corn Allergy", "No Pork", "No Ham", "No Beef", "No Mutton", "Halal", "No Red Meat", "None", ] drs = [] while prob() < 2: item = random.choice(rawDiet) rawDiet.remove(item) drs.append(item) hacker.dietary_restrictions = ",".join(drs) tms = [] while prob() < 2: tms.append("hacker_{0}@another.edu".format(random.randint(0, number))) hacker.teammates = ",".join(tms) hacker.hardware_hack = "yes" if prob() > 8 else "no" hacker.first_hackathon = "yes" if prob() > 7 else "no" def numberString(length): return "".join(map(lambda x: str(random.randint(0, 9)), range(0, length))) if prob() < 1: hacker.phone_number = numberString(10) # MOst will be confirmed, some will be waitlisted. if prob() < 8: hacker.rsvpd = True elif prob() < 3: hacker.waitlist_email_sent_date = datetime.datetime.now() states = [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY", ] hacker.address1 = "Creative" hacker.address2 = "Address" hacker.city = "City" hacker.country = "Country" hacker.state = random.choice(states) hacker.zip = numberString(5) if hacker.school == "Another University": hacker.rmax = 1000 else: hacker.rmax = 0 hacker.rtotal = random.randint(0, hacker.rmax) return hacker
def createTestHacker(number): shirts = ['XS', 'S', 'M', 'L', 'XL', 'XXL'] def prob(): return random.uniform(0.0, 10.0) hacker = Hacker() hacker.name = "Hacker {0}".format(number) hacker.school = "Brown University" if prob() < 3 else "Another University" hacker.year = "freshman" if prob() < 3: hacker.year = "sophomore" elif prob() < 3: hacker.year = "junior" elif prob() < 3: hacker.year = "senior" hacker.email = "hacker_{0}@{1}.edu".format( number, hacker.school.lower().split(" ")[0]) hacker.secret = generate_secret_for_hacker_with_email(hacker.email) hacker.shirt_gen = "M" if prob() < 5 else "W" hacker.shirt_size = random.choice(shirts) rawDiet = [ "Vegetarian", "Vegan", "Gluten Free", "Kosher", "Lactose Intolerant", "Nuts Allergy", "Treenuts Allergy", "Soy Allergy", "Shellfish Allergy", "Corn Allergy", "No Pork", "No Ham", "No Beef", "No Mutton", "Halal", "No Red Meat", "None" ] drs = [] while prob() < 2: item = random.choice(rawDiet) rawDiet.remove(item) drs.append(item) hacker.dietary_restrictions = ','.join(drs) tms = [] while prob() < 2: tms.append("hacker_{0}@another.edu".format(random.randint(0, number))) hacker.teammates = ','.join(tms) hacker.hardware_hack = "yes" if prob() > 8 else "no" hacker.first_hackathon = "yes" if prob() > 7 else "no" def numberString(length): return ''.join( map(lambda x: str(random.randint(0, 9)), range(0, length))) if prob() < 1: hacker.phone_number = numberString(10) #MOst will be confirmed, some will be waitlisted. if prob() < 8: hacker.rsvpd = True elif prob() < 3: hacker.waitlist_email_sent_date = datetime.datetime.now() states = [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ] hacker.address1 = "Creative" hacker.address2 = "Address" hacker.city = "City" hacker.country = "Country" hacker.state = random.choice(states) hacker.zip = numberString(5) if hacker.school == "Another University": hacker.rmax = 1000 else: hacker.rmax = 0 hacker.rtotal = random.randint(0, hacker.rmax) return hacker