-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathloadMockData.py
55 lines (46 loc) · 1.74 KB
/
loadMockData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from jersey_bidder import create_app, db, models
from jersey_bidder.models import *
from setUpSQL import setUp
import random
currentApp = create_app()
def integerToBlock(x):
if (x == 0):
return "A"
elif (x == 1):
return "B"
elif (x == 2):
return "C"
elif (x == 3):
return "D"
else:
return "E"
def loadMockData(app):
with app.app_context():
# MOCK DATA FOR TESTING
#mock 400 eusoffians
for i in range(400):
# create dummy user
currentRoomNumber = integerToBlock(i % 5) + str(i)
currentYear = (i % 4) + 1
currentPoints = i
currentEmail = "dummyEmail" + str(i) + "@gmail.com"
currentPassword = "dummyPassword" + str(i)
currentGender_id = i % 2 + 1
currentPreference_id = 0
if currentGender_id == 1:
# is a male
currentPreference_id = random.randint(1, 100)
else :
currentPreference_id = random.randint(101, 200)
currentUser = User(roomNumber = currentRoomNumber, year = currentYear, points = currentPoints,
email = currentEmail, password = currentPassword, gender_id = currentGender_id, preference_id=currentPreference_id)
db.session.add(currentUser)
# create sports
maleSport_id = [entries.id for entries in Sport.query.filter(Sport.gender_id == 1 or Sport.gender_id == 3)]
femaleSport_id = [entries.id for entries in Sport.query.filter(Sport.gender_id == 2 or Sport.gender_id == 3)]
#mock their choices
db.session.commit()
# setup database with base data
setUp(currentApp)
# load mock data
loadMockData(currentApp)