aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-06-09 13:24:52 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2017-06-09 13:24:52 -0700
commitd50a27b19bfdaf503e3e569d8a642591c49e7f19 (patch)
treedde34f95911f16f36ebe264848c79a978099a0e5
parent26438c9eec2a215687595fcfa6454c92c913a030 (diff)
downloadtrackermap-server-d50a27b19bfdaf503e3e569d8a642591c49e7f19.tar.gz
trackermap-server-d50a27b19bfdaf503e3e569d8a642591c49e7f19.tar.bz2
trackermap-server-d50a27b19bfdaf503e3e569d8a642591c49e7f19.zip
Add trip testing script
-rwxr-xr-xtools/test-trips.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/test-trips.py b/tools/test-trips.py
new file mode 100755
index 000000000..a71357fdb
--- /dev/null
+++ b/tools/test-trips.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import urllib
+import httplib
+import time
+import datetime
+
+id = '123456789012345'
+server = 'localhost:5055'
+
+points = [
+ ('2017-01-01 00:00:00', 59.93211887, 30.33050537, 0.0),
+ ('2017-01-01 00:05:00', 59.93266715, 30.33190012, 50.0),
+ ('2017-01-01 00:10:00', 59.93329069, 30.33333778, 50.0),
+ ('2017-01-01 00:15:00', 59.93390346, 30.33468962, 0.0),
+ ('2017-01-01 00:20:00', 59.93390346, 30.33468962, 0.0),
+ ('2017-01-01 00:25:00', 59.93416146, 30.33580542, 50.0),
+ ('2017-01-01 00:30:00', 59.93389271, 30.33790827, 50.0),
+ ('2017-01-01 00:35:00', 59.93357020, 30.34033298, 50.0),
+ ('2017-01-01 00:40:00', 59.93330144, 30.34252167, 0.0),
+ ('2017-01-01 00:44:00', 59.93355945, 30.34413099, 50.0),
+ ('2017-01-01 00:50:00', 59.93458072, 30.34458160, 0.0),
+ ('2017-01-01 00:55:00', 59.93458072, 30.34458160, 0.0),
+]
+
+def send(conn, time, lat, lon, speed):
+ params = (('id', id), ('timestamp', int(time)), ('lat', lat), ('lon', lon), ('speed', speed))
+ conn.request('POST', '?' + urllib.urlencode(params))
+ conn.getresponse().read()
+
+conn = httplib.HTTPConnection(server)
+
+for i in range(0, len(points)):
+ (moment, lat, lon, speed) = points[i]
+ send(conn, time.mktime(datetime.datetime.strptime(moment, "%Y-%m-%d %H:%M:%S").timetuple()), lat, lon, speed)