Disable ssl warnings for requests and refactor the dataset cleaner
This commit is contained in:
parent
7fd69b3205
commit
bdde91b660
@ -8,6 +8,7 @@ class ImportHelper:
|
||||
|
||||
@classmethod
|
||||
def import_test_dataset(cls, username, api_key, host):
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
url = "https://{0}.{1}/api/v1/imports/"\
|
||||
"?type_guessing=false&api_key={2}".format(
|
||||
username, host, api_key)
|
||||
@ -32,6 +33,7 @@ class ImportHelper:
|
||||
|
||||
@classmethod
|
||||
def get_imported_table_name(cls, username, host, api_key, import_id):
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
import_url = "https://{0}.{1}/api/v1/imports/{2}?api_key={3}".format(
|
||||
username, host, import_id, api_key)
|
||||
import_data_response = requests.get(import_url)
|
||||
@ -43,3 +45,14 @@ class ImportHelper:
|
||||
import_data_json = json.loads(import_data_response.text)
|
||||
|
||||
return import_data_json['table_name']
|
||||
|
||||
@classmethod
|
||||
def clean_test_dataset(cls, username, api_key, table_name, host):
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
url = "https://{0}.{1}/api/v2/sql?q=drop table {2}&api_key={3}".format(
|
||||
username, host, table_name, api_key
|
||||
)
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
print "Error cleaning the test dataset: {0}".format(response.text)
|
||||
sys.exit(1)
|
||||
|
@ -21,6 +21,7 @@ class IntegrationTestHelper:
|
||||
|
||||
@classmethod
|
||||
def execute_query(cls, sql_api_url, query):
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
query_url = "{0}?q={1}".format(sql_api_url, query)
|
||||
print "Executing query: {0}".format(query_url)
|
||||
query_response = requests.get(query_url)
|
||||
|
@ -1,8 +1,6 @@
|
||||
import getopt
|
||||
import sys
|
||||
import requests
|
||||
import time
|
||||
import json
|
||||
import subprocess
|
||||
import os
|
||||
from helpers.import_helper import ImportHelper
|
||||
@ -37,7 +35,7 @@ def main():
|
||||
sys.exit(1)
|
||||
finally:
|
||||
clean_environment_variables()
|
||||
clean_test_dataset(username, api_key, table_name, host)
|
||||
ImportHelper.clean_test_dataset(username, api_key, table_name, host)
|
||||
|
||||
|
||||
def usage():
|
||||
@ -65,15 +63,5 @@ def clean_environment_variables():
|
||||
del os.environ["GEOCODER_API_TEST_TABLE_NAME"]
|
||||
del os.environ["GEOCODER_API_TEST_HOST"]
|
||||
|
||||
|
||||
def clean_test_dataset(username, api_key, table_name, host):
|
||||
url = "https://{0}.{1}/api/v2/sql?q=drop table {2}&api_key={3}".format(
|
||||
username, host, table_name, api_key
|
||||
)
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
print "Error cleaning the test dataset: {0}".format(response.text)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user