diff --git a/test/helpers/integration_test_helper.py b/test/helpers/integration_test_helper.py index 02f18ee..76ffcd8 100644 --- a/test/helpers/integration_test_helper.py +++ b/test/helpers/integration_test_helper.py @@ -45,11 +45,15 @@ class IntegrationTestHelper: } @classmethod - def execute_query_raw(cls, sql_api_url, query): + def execute_query_raw(cls, sql_api_url, query, method='GET'): requests.packages.urllib3.disable_warnings() + if method.upper() == 'GET': query_url = "{0}?q={1}".format(sql_api_url, query) - print("Executing query: {0}".format(query_url)) query_response = requests.get(query_url) + print("Executing query GET: {0}".format(query_url)) + else: + query_response = requests.post(sql_api_url, data={"q": query}) + print("Executing query POST: {0}".format(sql_api_url)) if query_response.status_code != 200: raise Exception(json.loads(query_response.text)['error']) return json.loads(query_response.text) diff --git a/test/integration/test_street_functions.py b/test/integration/test_street_functions.py index fd1b983..8ddbce6 100644 --- a/test/integration/test_street_functions.py +++ b/test/integration/test_street_functions.py @@ -335,7 +335,7 @@ class TestBulkStreetFunctions(TestStreetFunctionsSetUp): "{}" \ "]''::jsonb) as (cartodb_id integer, address text)', " \ "'address', null, null, null, {})".format(','.join(streets), batch_size) - response = self._run_authenticated(query) + response = self._run_authenticated(query, method='POST') assert_equal(n, len(response['rows'])) for row in response['rows']: assert_not_equal(row['st_x'], None) @@ -413,12 +413,14 @@ class TestBulkStreetFunctions(TestStreetFunctionsSetUp): for r, e in zip(response['rows'], expected): self.assert_metadata(r['metadata'], e) - def _run_authenticated(self, query): - authenticated_query = "{}&api_key={}".format(query, - self.env_variables[ - 'api_key']) - return IntegrationTestHelper.execute_query_raw(self.sql_api_url, - authenticated_query) + def _run_authenticated(self, query, method='GET'): + api_key = self.env_variables['api_key'] + url = self.sql_api_url + auth_query = "{}&api_key={}".format(query, api_key) + if method.upper() != 'GET': + auth_query = query + url = "{}?api_key={}".format(self.sql_api_url, api_key) + return IntegrationTestHelper.execute_query_raw(url, auth_query, method) @staticmethod def _x_y_by_cartodb_id(response):