forked from UTSCCSCC01/Amble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupData.py
196 lines (180 loc) · 3.95 KB
/
setupData.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import requests
userUrl = 'http://localhost:8001'
locationUrl = 'http://localhost:8000'
tripUrl = 'http://localhost:8002'
#Configurations
userObj = {
"name": "TestName354",
"email": "[email protected]",
"password": "ILoveCS"
}
#Drivers
Drivers = [
{
"name": "Ritvik",
"email": "[email protected]",
"password": "Ritvik"
},
{
"name": "Kyrel",
"email": "[email protected]",
"password": "Kyrel"
},
{
"name": "Ethan",
"email": "[email protected]",
"password": "Ethan"
},
{
"name": "Daniil",
"email": "[email protected]",
"password": "Daniil"
},
{
"name": "Nivy",
"email": "[email protected]",
"password": "Nivy"
},
{
"name": "Chris",
"email": "[email protected]",
"password": "Chris"
},
{
"name": "Lance",
"email": "[email protected]",
"password": "Lance"
},
{
"name": "Manav",
"email": "[email protected]",
"password": "Manav"
}
]
Roads = [
{
"roadName": "U of T Underpass",
"hasTraffic": True
},
{
"roadName": "Liut Lights",
"hasTraffic": False
},
{
"roadName": "MN Drive",
"hasTraffic": True
},
{
"roadName": "Bergen Blvd",
"hasTraffic": False
},
{
"roadName": "Zingaro Zone",
"hasTraffic": True
},
{
"roadName": "Sushant Summit",
"hasTraffic": True
},
{
"roadName": "CCIT Corner",
"hasTraffic": False
},
{
"roadName": "Deerfield Dash",
"hasTraffic": False
},
{
"roadName": "Ilir Isle",
"hasTraffic": False
},
{
"roadName": "IB Island",
"hasTraffic": False
},
{
"roadName": "Sonya Street",
"hasTraffic": True
},
{
"roadName": "Petersen Park",
"hasTraffic": False
},
{
"roadName": "Kaneff St West",
"hasTraffic": True
},
{
"roadName": "Sauga Skyway",
"hasTraffic": False
},
{
"roadName": "Lisa Lane",
"hasTraffic": False
},
{
"roadName": "Davis Dungeon",
"hasTraffic": False
},
{
"roadName": "Michael Meadows",
"hasTraffic": True
}
]
RoadConnections = {
"U of T Underpass": [("Liut Lights", 4), ("Bergen Blvd", 10), ("Deerfield Dash", 14), ("Sonya Street", 20), ("Sauga Skyway", 22), ("Kaneff St West", 24), ("Michael Meadows", 30)],
"Liut Lights": [("MN Drive", 4)],
"Bergen Blvd": [("Zingaro Zone", 4)],
"Zingaro Zone": [("Sushant Summit", 4)],
"Sushant Summit": [("CCIT Corner", 4)],
"Deerfield Dash": [("Ilir Isle", 6)],
"Sonya Street": [("IB Island", 4), ("Petersen Park", 8)],
"Sauga Skyway": [("Lisa Lane", 8)],
"Kaneff St West": [("Lisa Lane", 8)],
"Michael Meadows": [("Davis Dungeon", 10)]
}
def createUser(userObj, isDriver):
req = requests.post(userUrl + '/user/register', json=userObj)
uid = None
if (req.status_code == 200):
uid = req.json()['uid']
req = requests.put(locationUrl + '/location/user', json={"uid": uid, "is_driver": isDriver})
print(req)
if (req.status_code == 200):
req = requests.patch(locationUrl + f'/location/{uid}',json={"latitude": 0.0, "longitude": 0.0, "street": "Liut Lights"})
print(req)
return uid
print("Creating User...")
# Create user
createUser(userObj, False)
print("Creating Drivers...")
for driver in Drivers:
uid = createUser(driver, True)
if uid != None:
req = requests.patch(userUrl + f'/user/{uid}', json={"isDriver": True})
print(req)
print("Creating Roads...")
# Create Roads
for road in Roads:
req = requests.put(locationUrl + '/location/road', json=road)
print(req)
print("Creating Road Connections...")
# Create Road Conncetions
for roadOne, roadTups in RoadConnections.items():
for roadTwo, time in roadTups:
req = requests.post(locationUrl + '/location/hasRoute',json = {
"roadName1": roadOne,
"roadName2": roadTwo,
"time": time,
"hasTraffic": False
})
print(req)
# These are all two way roads
req = requests.post(locationUrl + '/location/hasRoute',json = {
"roadName1": roadTwo,
"roadName2": roadOne,
"time": time,
"hasTraffic": False
})
print(req)
print("Done creating data.")