-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmassAdd.py
41 lines (31 loc) · 1.11 KB
/
massAdd.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
import requests
import random
import hashlib
import json
url="http://parisx:9200/universities/universities/"
def assignClasses():
classes=[]
for x in range(random.randrange(1,6)):
classes.append(genclass())
return classes
schools = ("Arizona State University", "University of South Carolina - Columbia", "University of North Carolina at Chapel Hill")
firstNames = ("Walker", "Stephen", "Julie", "George")
lastNames = ("Rowe", "Shakespeare", "Mann", "Sarte")
courses= ("math", "physics", "French", "logic")
def genclass():
classes={}
classes["name"]=courses[random.randrange(0,3)]
classes["grades"] = random.randrange(1,7)
return classes
def genStudent():
students={}
students["school"]=schools[random.randrange(0,3)]
students["firstName"] = firstNames[random.randrange(0,3)]
students["lastName"] = lastNames[random.randrange(0,3)]
students["classes"] = assignClasses()
m = hashlib.sha1()
m.update(bytes(json.dumps(students), 'utf-8'))
id = m.hexdigest()
response = requests.post(url + id, json=students)
for r in range(1,400):
genStudent()