forked from UTSCCSCC01/Amble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanitychecker.py
118 lines (102 loc) · 2.38 KB
/
sanitychecker.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
import requests
#Modified version of setupData to test dijsktra algorithm
#
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"
},
]
Roads = [
{
"roadName": "a",
"hasTraffic": True
},
{
"roadName": "b",
"hasTraffic": False
},
{
"roadName": "c",
"hasTraffic": True
},
{
"roadName": "d",
"hasTraffic": False
},
{
"roadName": "e",
"hasTraffic": True
},
{ #Not connected to anything
"roadName": "f",
"hasTraffic": True
}
]
RoadConnections = {
"a": [("b", 1), ("c", 6)],
"b": [("c", 2),("d", 1)],
"c": [("d",2),("e",5)],
"d": [("e",5)],
}
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.")