Quota test

This commit is contained in:
Juan Ignacio Sánchez Lara 2018-07-17 14:39:24 +02:00
parent 5e8dbaf239
commit 5e34faefe5
2 changed files with 10 additions and 0 deletions

View File

@ -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]))

View File

@ -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\"}]' " \