-
Notifications
You must be signed in to change notification settings - Fork 3
/
simulatelocations.py
320 lines (259 loc) · 8.75 KB
/
simulatelocations.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import sys
import requests
import time
path1 = [(43, -87), (32, -120)]
park = (42.056838, -87.675940)
burgers = (42.046131, -87.681559)
grocery = (42.047621, -87.679488)
grocery2 = (42.039818,-87.680088)
coffee = (42.046881, -87.679555)
# beer = (42.047105, -87.682006)
bars = (42.046251, -87.680547)
sydney = (-33, 151)
train = (42.053872,-87.683748)
brisbane = (-37.822464, 144.966146)
library = (42.058141, -87.674490)
def followPath(path, uid):
for stop in path:
setLocation(stop, uid)
time.sleep(1)
def setLocation(location, uid):
host = "http://localhost:3000"
# host = "https://ce-platform.herokuapp.com"
# host = "https://staging-ce-platform.herokuapp.com"
r = requests.post(host + "/api/geolocation", json={
"userId": uid,
"location": {
"coords": {
"latitude": location[0],
"longitude": location[1]
},
"activity": {"type": "unknown", "confidence": 100}
}
})
#print(uid + "at location " + str(location[0]) + " " + str(location[1]))
# db.locations.update(
# { uid: "kTwXH8rAHeutLDD83" },
# { "$set": {"affordances.sunset": true}}
# )
#This test checks that users receive experiences when they get an affordance
# and then loose the correct experiences when they loose the affordance
def basicUserMovement():
print("Log in as all users")
#time.sleep(10)
setLocation(park, sys.argv[1])
print("User A should now have two experiences, participate in scavenger hunt")
print("after participating, user A should only have restaurant!")
time.sleep(20)
setLocation(park, sys.argv[2])
print("user B should now have two experiences")
time.sleep(20)
setLocation(burgers, sys.argv[2])
print("user B should now have one experience")
def threeUsersMoving():
print("Log in as all users")
time.sleep(5)
setLocation(park, sys.argv[1])
print("User A should now have two experiences")
time.sleep(20)
setLocation(park, sys.argv[2])
print("user B should now have two experiences")
time.sleep(20)
setLocation(burgers, sys.argv[2])
print("user B should now have one experience")
time.sleep(20)
setLocation(park, sys.argv[3])
print("user C should now have two experiences")
time.sleep(20)
setLocation(park, sys.argv[2])
print("user B changes locations but should not gain experiences")
def userWaitsBetweenNotifications():
print("Log in as all users")
time.sleep(5)
setLocation(park, sys.argv[1])
print("User A should now have two experiences")
print("Participate in one experience")
time.sleep(20)
print("participation should be done by now")
print("User should not regain experiences")
setLocation(park, sys.argv[1])
time.sleep(50)
setLocation(park, sys.argv[1])
print("User should regain experience!")
def threeUsersParticipateInExperiences():
print("Log in as all users")
time.sleep(5)
setLocation(park, sys.argv[1])
# time.sleep(10)
setLocation(park, sys.argv[2])
# time.sleep(20)
# setLocation(park, sys.argv[3])
# print("User C should now have one experiences")
# time.sleep(10)
# setLocation(park, sys.argv[1])
# print("User A should have one experiences")
# print("Participate in restaurant")
# time.sleep(10)
# setLocation(burgers, sys.argv[2])
# print("User B should have no experiences")
# time.sleep(5)
setLocation(burgers, sys.argv[3])
# time.sleep(10)
def oneUserMoving():
print("Log in as user a")
time.sleep(2)
setLocation(park, sys.argv[1])
print("location set to park")
time.sleep(2)
setLocation((42.056836, -87.675941), sys.argv[1])
print("slight movement 1")
time.sleep(2)
setLocation((42.056830, -87.67595), sys.argv[1])
print("slight movement 2")
time.sleep(2)
setLocation((42.056835, -87.675942), sys.argv[1])
print("slight movement 3")
time.sleep(2)
setLocation((42.05684, -87.67593), sys.argv[1])
print("slight movement 4")
time.sleep(2)
setLocation((42.05685, -87.67592), sys.argv[1])
print("slight movement")
def test5():
while(True):
print("josh goes to the train")
setLocation(train, sys.argv[5])
time.sleep(15)
print("garrett gets to the grocery store")
setLocation(grocery, sys.argv[1])
print("meg gets to the bar")
setLocation(beer, sys.argv[3])
time.sleep(15)
print("garretts brother gets to the grocery store")
setLocation(grocery, sys.argv[2])
time.sleep(15)
print("megs sister gets to the bar")
setLocation(beer, sys.argv[4])
time.sleep(15)
print("josh gets to the park")
setLocation(park, sys.argv[5])
time.sleep(15)
print("meg and her sister goes to the train")
setLocation(train, sys.argv[3])
setLocation(train, sys.argv[4])
time.sleep(15)
print("garrett goes to a park")
setLocation(park, sys.argv[1])
time.sleep(15)
print("garrett goes to the train")
setLocation(train, sys.argv[1])
time.sleep(15)
def allUsersAtPark():
setLocation(park, sys.argv[1])
setLocation(park, sys.argv[2])
setLocation(park, sys.argv[3])
setLocation(park, sys.argv[4])
setLocation(park, sys.argv[5])
print("all usrs at parks")
def allUsersAtCastle():
setLocation((42.050538,-87.677355), sys.argv[1])
setLocation((42.050538,-87.677355), sys.argv[2])
setLocation((42.050538,-87.677355), sys.argv[3])
setLocation((42.050538,-87.677355), sys.argv[4])
setLocation((42.050538,-87.677355), sys.argv[5])
print("all usrs at castle")
def allUsersAtRestaurant():
setLocation(burgers, sys.argv[1])
setLocation(burgers, sys.argv[2])
setLocation(burgers, sys.argv[3])
print("all users at burgers")
def allUsersAtGrocery():
setLocation(grocery, sys.argv[1])
setLocation(grocery, sys.argv[2])
setLocation(grocery, sys.argv[3])
setLocation(grocery, sys.argv[3])
setLocation(grocery, sys.argv[3])
print("all users at grocery")
def allUsersAtBars():
setLocation(bars, sys.argv[1])
setLocation(bars, sys.argv[2])
setLocation(bars, sys.argv[3])
setLocation(bars, sys.argv[4])
setLocation(bars, sys.argv[5])
print("all users at bar")
def allUsersAtTrain():
setLocation(train, sys.argv[1])
setLocation(train, sys.argv[2])
setLocation(train, sys.argv[3])
setLocation(train, sys.argv[4])
setLocation(train, sys.argv[5])
print("all users at train")
def userAatCoffee():
setLocation(coffee, sys.argv[1])
def userAatBar():
setLocation(beer, sys.argv[1])
def userAatGrocery():
setLocation(grocery, sys.argv[1])
def allUsersCalifornia():
setLocation((34, -120), sys.argv[1])
setLocation((34, -120), sys.argv[2])
setLocation((34, -120), sys.argv[3])
setLocation((34, -120), sys.argv[4])
setLocation((34, -120), sys.argv[5])
print("all users in CA")
def allUsersSyd():
setLocation(sydney, sys.argv[1])
setLocation(sydney, sys.argv[2])
setLocation(sydney, sys.argv[3])
setLocation(sydney, sys.argv[4])
setLocation(sydney, sys.argv[5])
print("all users in sydney")
def allUsersLakefill():
setLocation((42.052460,-87.669876), sys.argv[1])
setLocation((42.052460,-87.669876), sys.argv[2])
setLocation((42.052460,-87.669876), sys.argv[3])
setLocation((42.052460,-87.669876), sys.argv[4])
setLocation((42.052460,-87.669876), sys.argv[5])
print("all users in lakefill")
def onlyGarretAtLake():
setLocation((42.052460,-87.669876), sys.argv[1])
setLocation(train, sys.argv[2])
setLocation(train, sys.argv[3])
setLocation(train, sys.argv[4])
setLocation(train, sys.argv[5])
print("only garrett at lakefill")
def garrettAndMegBump():
setLocation(grocery, sys.argv[1])
setLocation(grocery, sys.argv[3])
setLocation(train, sys.argv[2])
setLocation(train, sys.argv[4])
setLocation(train, sys.argv[5])
print("meg and garret at grocery")
def allUsersGrocery():
setLocation(grocery, sys.argv[1])
setLocation(grocery, sys.argv[2])
setLocation(grocery, sys.argv[3])
setLocation(grocery, sys.argv[4])
setLocation(grocery, sys.argv[5])
print("all users at grocery")
def allUsersCoffee():
for i in sys.argv:
setLocation(coffee, i)
print("all users at coffee")
if __name__ == "__main__":
# allUsersGrocery()
allUsersCoffee()
# allUsersAtBars()
#allUsersAtPark()
# garrettAndMegBump()
# single user movement
# setLocation(burgers, sys.argv[1])
# allUsersGrocery()
# garrettAndMegBump()
# single user movement
# setLocation(burgers, sys.argv[1])
# allUsersGrocery()
# allUsersAtBars()
#garrettAndMegBump()
#time.sleep(2)
#onlyGarretAtLake()