Added new logger to all the functions
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import unittest
|
||||
import requests_mock
|
||||
from mock import Mock
|
||||
|
||||
from cartodb_services.google import GoogleMapsGeocoder
|
||||
from cartodb_services.google.exceptions import BadGeocodingParams
|
||||
@@ -89,8 +90,9 @@ class GoogleGeocoderTestCase(unittest.TestCase):
|
||||
MALFORMED_RESPONSE = """{"manolo": "escobar"}"""
|
||||
|
||||
def setUp(self):
|
||||
logger = Mock()
|
||||
self.geocoder = GoogleMapsGeocoder('dummy_client_id',
|
||||
'MgxyOFxjZXIyOGO52jJlMzEzY1Oqy4hsO49E')
|
||||
'MgxyOFxjZXIyOGO52jJlMzEzY1Oqy4hsO49E', logger)
|
||||
|
||||
def test_geocode_address_with_valid_params(self, req_mock):
|
||||
req_mock.register_uri('GET', self.GOOGLE_MAPS_GEOCODER_URL,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from datetime import datetime, date
|
||||
from mock import Mock
|
||||
import sys
|
||||
sys.modules['plpy'] = Mock()
|
||||
|
||||
|
||||
def build_redis_user_config(redis_conn, username, quota=100, soft_limit=False,
|
||||
@@ -72,3 +74,5 @@ def _plpy_execute_side_effect(*args, **kwargs):
|
||||
return [{'conf': '{"geocoder_log_path": "/dev/null"}'}]
|
||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('data_observatory_conf') as conf":
|
||||
return [{'conf': '{"connection": {"whitelist": ["ethervoid"], "production": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api", "staging": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api"}}'}]
|
||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('server_conf') as conf":
|
||||
return [{'conf': '{"environment": "testing"}'}]
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import unittest
|
||||
import requests_mock
|
||||
from mock import Mock
|
||||
|
||||
from cartodb_services.here import HereMapsGeocoder
|
||||
from cartodb_services.here.exceptions import BadGeocodingParams
|
||||
@@ -102,7 +103,8 @@ class HereMapsGeocoderTestCase(unittest.TestCase):
|
||||
MALFORMED_RESPONSE = """{"manolo": "escobar"}"""
|
||||
|
||||
def setUp(self):
|
||||
self.geocoder = HereMapsGeocoder(None, None)
|
||||
logger = Mock()
|
||||
self.geocoder = HereMapsGeocoder(None, None, logger)
|
||||
|
||||
def test_geocode_address_with_valid_params(self, req_mock):
|
||||
req_mock.register_uri('GET', HereMapsGeocoder.PRODUCTION_GEOCODE_JSON_URL,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import unittest
|
||||
import requests_mock
|
||||
from mock import Mock
|
||||
from urlparse import urlparse, parse_qs
|
||||
|
||||
from cartodb_services.here import HereMapsRoutingIsoline
|
||||
@@ -127,7 +128,8 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase):
|
||||
MALFORMED_RESPONSE = """{"manolo": "escobar"}"""
|
||||
|
||||
def setUp(self):
|
||||
self.routing = HereMapsRoutingIsoline(None, None)
|
||||
logger = Mock()
|
||||
self.routing = HereMapsRoutingIsoline(None, None, logger)
|
||||
self.isoline_url = "{0}{1}".format(HereMapsRoutingIsoline.PRODUCTION_ROUTING_BASE_URL,
|
||||
HereMapsRoutingIsoline.ISOLINE_PATH)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/local/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import mock
|
||||
import unittest
|
||||
import requests_mock
|
||||
from mock import Mock
|
||||
|
||||
from cartodb_services.mapzen import MapzenGeocoder
|
||||
from cartodb_services.mapzen.exceptions import MalformedResult
|
||||
@@ -88,7 +89,8 @@ class MapzenGeocoderTestCase(unittest.TestCase):
|
||||
MALFORMED_RESPONSE = """{"manolo": "escobar"}"""
|
||||
|
||||
def setUp(self):
|
||||
self.geocoder = MapzenGeocoder('search-XXXXXXX')
|
||||
logger = Mock()
|
||||
self.geocoder = MapzenGeocoder('search-XXXXXXX', logger)
|
||||
|
||||
def test_geocode_address_with_valid_params(self, req_mock):
|
||||
req_mock.register_uri('GET', self.MAPZEN_GEOCODER_URL,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
from mock import Mock
|
||||
from cartodb_services.mapzen import MapzenIsolines
|
||||
from math import radians, cos, sin, asin, sqrt
|
||||
|
||||
@@ -10,6 +11,7 @@ It uses a mocked client, which returns the cost based on a very simple model:
|
||||
just proportional to the distance from origin to the target point.
|
||||
"""
|
||||
|
||||
|
||||
class MatrixClientMock():
|
||||
|
||||
def __init__(self, speed):
|
||||
@@ -67,7 +69,7 @@ class MapzenIsolinesTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
speed = 4 # in km/h
|
||||
matrix_client = MatrixClientMock(speed)
|
||||
self.mapzen_isolines = MapzenIsolines(matrix_client)
|
||||
self.mapzen_isolines = MapzenIsolines(matrix_client, Mock())
|
||||
|
||||
def test_calculate_isochrone(self):
|
||||
origin = {"lat":40.744014,"lon":-73.990508}
|
||||
|
||||
@@ -6,6 +6,7 @@ import requests_mock
|
||||
import re
|
||||
from nose.tools import assert_raises
|
||||
from urlparse import urlparse, parse_qs
|
||||
from mock import Mock
|
||||
|
||||
from cartodb_services.mapzen import MapzenRouting, MapzenRoutingResponse
|
||||
from cartodb_services.mapzen.exceptions import WrongParams
|
||||
@@ -99,7 +100,8 @@ class MapzenRoutingTestCase(unittest.TestCase):
|
||||
MALFORMED_RESPONSE = """{"manolo": "escobar"}"""
|
||||
|
||||
def setUp(self):
|
||||
self.routing = MapzenRouting('api_key')
|
||||
logger = Mock()
|
||||
self.routing = MapzenRouting('api_key', logger)
|
||||
self.url = MapzenRouting.PRODUCTION_ROUTING_BASE_URL
|
||||
|
||||
def test_calculate_simple_routing_with_valid_params(self, req_mock):
|
||||
|
||||
Reference in New Issue
Block a user