From 5e34faefe55ce80d0fe91d9938f92e96f58f7559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Tue, 17 Jul 2018 14:39:24 +0200 Subject: [PATCH] Quota test --- .../python/cartodb_services/cartodb_services/geocoder.py | 1 + test/integration/test_street_functions.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/server/lib/python/cartodb_services/cartodb_services/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/geocoder.py index 465118d..54e80f1 100644 --- a/server/lib/python/cartodb_services/cartodb_services/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/geocoder.py @@ -17,6 +17,7 @@ def geocoder_metadata(relevance, precision, match_types): 'match_types': match_types } + def compose_address(street, city=None, state=None, country=None): return ', '.join(filter(None, [street, city, state, country])) diff --git a/test/integration/test_street_functions.py b/test/integration/test_street_functions.py index a847637..ebcc26f 100644 --- a/test/integration/test_street_functions.py +++ b/test/integration/test_street_functions.py @@ -131,6 +131,11 @@ class TestStreetFunctionsSetUp(TestCase): return IntegrationTestHelper.execute_query_raw(self.sql_api_url, authenticated_query) + def _used_quota(self): + query = "select used_quota " \ + "from cdb_dataservices_client.cdb_service_quota_info() " \ + "where service = 'hires_geocoder'" + return self._run_authenticated(query)['rows'][0]['used_quota'] class TestStreetFunctions(TestStreetFunctionsSetUp): @@ -305,6 +310,8 @@ class TestBulkStreetFunctions(TestStreetFunctionsSetUp): 'Toronto, Canada"}}'.format(first_cartodb_id + i, first_street_number + i)) + used_quota = self._used_quota() + query = "select *, st_x(the_geom), st_y(the_geom) " \ "FROM cdb_dataservices_client.cdb_bulk_geocode_street_point( " \ "'select * from jsonb_to_recordset(''[" \ @@ -321,6 +328,8 @@ class TestBulkStreetFunctions(TestStreetFunctionsSetUp): assert_not_equal(metadata['precision'], None) assert_not_equal(metadata['match_types'], None) + assert_equal(self._used_quota(), used_quota + n) + def test_missing_components_on_private_function(self): query = "SELECT _cdb_bulk_geocode_street_point(" \ " '[{\"id\": \"1\", \"address\": \"Amphitheatre Parkway 22\"}]' " \