Exemple #1
0
import urllib
import json
import server

testedServer = server.Server()
id = server.create_event(5, 7)
print "id=%s" % id
Exemple #2
0
import urllib
import json
import server


testedServer = server.Server()
id=server.create_event(5,7)
print "id=%s" % id
Exemple #3
0
import urllib
import json
import server


testedServer = server.Server()
data = urllib.urlopen( "http://localhost:8000/all_events").read()
result = json.loads( data )
assert (result["events"] == [])

server.create_event(5,5)

result=server.all_events()
print result
assert (len(result["events"]) == 1)
assert (result["events"][0]["latitude"] == 5)
assert (result["events"][0]["longitude"] == 5)


rescuer = {
    "name": "Cookie monster",
    "phone_number": "052-555-4444",
    "rank": "trashcan manager",
    "latitude": 32.43243,
    "longitude": 35.432
}

# No events yet - expect empty response
data = urllib.urlopen("http://localhost:8000/nearby_events",
                      json.dumps(rescuer)).read()
result = json.loads(data)
assert (result == {"events": []})

# Add an event
id = server.create_event(32.43243, 35.432)
# data = urllib.urlopen( "http://localhost:8000/new_event/32.43243/35.432").read()
# assert (data == "")

# Check that rescuer exists now
returned_rescuer = server.get_rescuer_by_phone(rescuer["phone_number"])
assert (returned_rescuer)
assert (returned_rescuer["phone_number"] == rescuer["phone_number"])
common_keys = [key for key in rescuer.keys() if key in returned_rescuer.keys()]
expected_keys = sorted(['phone_number', 'latitude', 'longitude', 'rank'])

assert (expected_keys == sorted(common_keys))
for key in common_keys:
    assert (returned_rescuer[key] == rescuer[key])

# Now expect to get the event back
Exemple #5
0
import urllib
import json
import server

testedServer = server.Server()
data = urllib.urlopen("http://localhost:8000/all_events").read()
result = json.loads(data)
assert (result["events"] == [])

server.create_event(5, 5)

result = server.all_events()
print result
assert (len(result["events"]) == 1)
assert (result["events"][0]["latitude"] == 5)
assert (result["events"][0]["longitude"] == 5)