Pythonic refactor, importing single method

This commit is contained in:
Juan Ignacio Sánchez Lara 2018-02-13 18:23:36 +01:00
parent 029541f298
commit 1fdb4d3b3a
4 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@ import unittest
from mock import Mock from mock import Mock
from cartodb_services.mapbox import MapboxGeocoder from cartodb_services.mapbox import MapboxGeocoder
from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools.exceptions import ServiceException
import credentials from credentials import mapbox_api_key
INVALID_TOKEN = 'invalid_token' INVALID_TOKEN = 'invalid_token'
VALID_ADDRESS = 'Calle Siempreviva 3, Valladolid' VALID_ADDRESS = 'Calle Siempreviva 3, Valladolid'
@ -12,7 +12,7 @@ WELL_KNOWN_LATITUDE = 41.668654
class MapboxGeocoderTestCase(unittest.TestCase): class MapboxGeocoderTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.geocoder = MapboxGeocoder(token=credentials.mapbox_api_key(), logger=Mock()) self.geocoder = MapboxGeocoder(token=mapbox_api_key(), logger=Mock())
def test_invalid_token(self): def test_invalid_token(self):
invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN, logger=Mock()) invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN, logger=Mock())

View File

@ -7,7 +7,7 @@ from cartodb_services.mapbox.routing import MapboxRouting
from cartodb_services.tools import Coordinate from cartodb_services.tools import Coordinate
from cartodb_services.tools.coordinates import (validate_coordinates, from cartodb_services.tools.coordinates import (validate_coordinates,
marshall_coordinates) marshall_coordinates)
import credentials from credentials import mapbox_api_key
VALID_ORIGIN = Coordinate(-73.989, 40.733) VALID_ORIGIN = Coordinate(-73.989, 40.733)
@ -15,7 +15,7 @@ VALID_ORIGIN = Coordinate(-73.989, 40.733)
class MapboxIsolinesTestCase(unittest.TestCase): class MapboxIsolinesTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), logger=Mock()) matrix_client = MapboxMatrixClient(token=mapbox_api_key(), logger=Mock())
self.mapbox_isolines = MapboxIsolines(matrix_client, logger=Mock()) self.mapbox_isolines = MapboxIsolines(matrix_client, logger=Mock())
def test_calculate_isochrone(self): def test_calculate_isochrone(self):

View File

@ -4,7 +4,7 @@ from cartodb_services.mapbox import MapboxMatrixClient
from cartodb_services.mapbox.matrix_client import DEFAULT_PROFILE from cartodb_services.mapbox.matrix_client import DEFAULT_PROFILE
from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools.exceptions import ServiceException
from cartodb_services.tools import Coordinate from cartodb_services.tools import Coordinate
import credentials from credentials import mapbox_api_key
INVALID_TOKEN = 'invalid_token' INVALID_TOKEN = 'invalid_token'
VALID_ORIGIN = Coordinate(-73.989, 40.733) VALID_ORIGIN = Coordinate(-73.989, 40.733)
@ -22,7 +22,7 @@ INVALID_PROFILE = 'invalid_profile'
class MapboxMatrixTestCase(unittest.TestCase): class MapboxMatrixTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), self.matrix_client = MapboxMatrixClient(token=mapbox_api_key(),
logger=Mock()) logger=Mock())
def test_invalid_profile(self): def test_invalid_profile(self):

View File

@ -4,7 +4,7 @@ from cartodb_services.mapbox import MapboxRouting
from cartodb_services.mapbox.routing import DEFAULT_PROFILE from cartodb_services.mapbox.routing import DEFAULT_PROFILE
from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools.exceptions import ServiceException
from cartodb_services.tools import Coordinate from cartodb_services.tools import Coordinate
import credentials from credentials import mapbox_api_key
INVALID_TOKEN = 'invalid_token' INVALID_TOKEN = 'invalid_token'
VALID_WAYPOINTS = [Coordinate(-73.989, 40.733), Coordinate(-74, 40.733)] VALID_WAYPOINTS = [Coordinate(-73.989, 40.733), Coordinate(-74, 40.733)]
@ -31,7 +31,7 @@ WELL_KNOWN_LENGTH = 1317.9
class MapboxRoutingTestCase(unittest.TestCase): class MapboxRoutingTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.routing = MapboxRouting(token=credentials.mapbox_api_key(), logger=Mock()) self.routing = MapboxRouting(token=mapbox_api_key(), logger=Mock())
def test_invalid_profile(self): def test_invalid_profile(self):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):