Pure Python implementation of clients for Mapbox services

This commit is contained in:
Antonio
2017-12-27 13:43:14 +01:00
parent b16f7e6ed5
commit 8c0af7d51d
13 changed files with 620 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
import unittest
from cartodb_services.mapbox import MapboxGeocoder
from cartodb_services.mapbox import ServiceException
INVALID_TOKEN = 'invalid_token'
VALID_ADDRESS = 'Calle Siempreviva 3, Valladolid'
WELL_KNOWN_LONGITUDE = -4.730947
WELL_KNOWN_LATITUDE = 41.668654
class MapboxGeocoderTestCase(unittest.TestCase):
def setUp(self):
self.geocoder = MapboxGeocoder()
def test_invalid_token(self):
invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN)
with self.assertRaises(ServiceException):
invalid_geocoder.geocode(VALID_ADDRESS)
def test_valid_request(self):
place = self.geocoder.geocode(VALID_ADDRESS)
self.assertEqual(place[0], WELL_KNOWN_LONGITUDE)
self.assertEqual(place[1], WELL_KNOWN_LATITUDE)