In case of general error, failed service use should be incremented by searches length
This commit is contained in:
parent
fd097724f1
commit
cd5e6510a6
@ -54,11 +54,13 @@ def run_street_point_geocoder(plpy, GD, geocoder, service_manager, username, org
|
||||
service_manager.quota_service.increment_empty_service_use(len(searches))
|
||||
return []
|
||||
except QuotaExceededException as qe:
|
||||
logger.debug('QuotaExceededException at run_street_point_geocoder', qe,
|
||||
data={"username": username, "orgname": orgname})
|
||||
service_manager.quota_service.increment_failed_service_use(len(searches))
|
||||
return []
|
||||
except BaseException as e:
|
||||
import sys
|
||||
service_manager.quota_service.increment_failed_service_use()
|
||||
service_manager.quota_service.increment_failed_service_use(len(searches))
|
||||
service_manager.logger.error('Error trying to bulk geocode street point', sys.exc_info(), data={"username": username, "orgname": orgname})
|
||||
raise Exception('Error trying to bulk geocode street')
|
||||
finally:
|
||||
|
@ -8,11 +8,13 @@ from cartodb_services.geocoder import run_street_point_geocoder
|
||||
|
||||
|
||||
class TestRunStreetPointGeocoder(TestCase):
|
||||
def test_count_increment_total_service_use_on_error(self):
|
||||
def test_count_increment_total_and_failed_service_use_on_error(self):
|
||||
quota_service_mock = Mock()
|
||||
|
||||
service_manager_mock = Mock()
|
||||
service_manager_mock.quota_service = quota_service_mock
|
||||
service_manager_mock.assert_within_limits = \
|
||||
Mock(side_effect=Exception('Fail!'))
|
||||
|
||||
searches = []
|
||||
|
||||
@ -27,3 +29,6 @@ class TestRunStreetPointGeocoder(TestCase):
|
||||
|
||||
quota_service_mock.increment_total_service_use. \
|
||||
assert_called_once_with(len(searches))
|
||||
|
||||
quota_service_mock.increment_failed_service_use. \
|
||||
assert_called_once_with(len(searches))
|
||||
|
Loading…
Reference in New Issue
Block a user