def test_parse_result_with_unknown_lat_lon(): # http://open.mapquestapi.com/geocoding/v1/address?location=abcdefghijklmnopqrstuvwxyz&key=key_goes_here&format=json results = { "results": [{ "locations": [{ "latLng": { "lat": 39.78373, "lng": -100.445882 } }] }] } res = geolocation.parse_result(results) assert res is None, res
def test_parse_result_with_lat_lon(): # http://open.mapquestapi.com/geocoding/v1/address?location=abcdefghijklmnopqrstuvwxyz&key=key_goes_here&format=json results = { "results": [{ "locations": [{ "latLng": { "lat": 123.00, "lng": -142.99 } }] }] } res = geolocation.parse_result(results) assert res == results, res
def test_parse_result_with_unknown_lat_lon(): # http://open.mapquestapi.com/geocoding/v1/address?location=abcdefghijklmnopqrstuvwxyz&key=key_goes_here&format=json results = { "results": [ { "locations": [ { "latLng": { "lat": 39.78373, "lng": -100.445882 } } ] } ] } res = geolocation.parse_result(results) assert res is None, res
def test_parse_result_with_lat_lon(): # http://open.mapquestapi.com/geocoding/v1/address?location=abcdefghijklmnopqrstuvwxyz&key=key_goes_here&format=json results = { "results": [ { "locations": [ { "latLng": { "lat": 123.00, "lng": -142.99 } } ] } ] } res = geolocation.parse_result(results) assert res == results, res
def test_parse_result_with_city(): # http://open.mapquestapi.com/nominatim/v1/reverse.php?lat=37.368&lon=-122.03&key=key_goes_here&format=json results = { "place_id": "60197412", "osm_type": "way", "osm_id": "30907961", "lat": "37.36746105", "lon": "-122.030237558742", "display_name": "111, East El Camino Real, Sunnyvale, Santa Clara County, California, 94087, United States of America", "address": { "house_number": "111", "road": "East El Camino Real", "city": "Sunnyvale", "county": "Santa Clara County", "state": "California", "postcode": "94087", "country": "United States of America", "country_code": "us" } } res = geolocation.parse_result(results) assert res == results, res
def test_parse_result_with_error(): res = geolocation.parse_result({'error': 'foo'}) assert res is None, res