Skip to content

Commit 4a3e0f7

Browse files
committed
Add comments, improve code quality and change api key
1 parent 0af2533 commit 4a3e0f7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

tests_and_examples/run_query_tests.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@
3434
class SlicingDiceTester(object):
3535
"""Test orchestration class."""
3636
def __init__(self, api_key, verbose=False, endpoint_test=True):
37+
# The Slicing Dice API client
3738
self.client = SlicingDice(api_key)
3839
self.endpoint_test = endpoint_test
3940

4041
# Translation table for fields with timestamp
4142
self.field_translation = {}
4243

43-
self.sleep_time = int(os.environ.get("CLIENT_SLEEP_TIME", 5)) # seconds
44-
self.path = 'examples/' # Directory containing examples to test
45-
self.extension = '.json' # Examples file format
44+
# Sleep time in seconds
45+
self.sleep_time = int(os.environ.get("CLIENT_SLEEP_TIME", 5))
46+
# Directory containing examples to test
47+
self.path = 'examples/'
48+
# Examples file format
49+
self.extension = '.json'
4650

4751
self.num_successes = 0
4852
self.num_fails = 0
@@ -86,7 +90,8 @@ def run_tests(self, query_type):
8690
print
8791

8892
def _empty_field_translation(self):
89-
"""Empty field translation table so tests don't intefere each other."""
93+
"""Erase field translation table so tests don't interfere each
94+
other."""
9095
self.field_translation = {}
9196

9297
def load_test_data(self, query_type):
@@ -170,7 +175,6 @@ def index_data(self, test):
170175
Parameters:
171176
test -- Dictionary containing test name, fields metadata, data to be
172177
indexed, query, and expected results.
173-
auto_create -- Auto create a field if not exists.
174178
"""
175179
is_singular = len(test['index']) == 1
176180
entity_or_entities = 'entity' if is_singular else 'entities'
@@ -289,18 +293,17 @@ def main():
289293
# Testing class with demo API key or one of your API key
290294
# by enviroment variable
291295
# http://panel.slicingdice.com/docs/#api-details-api-connection-api-keys-demo-key
292-
293-
API_KEY = os.environ.get(
296+
api_key = os.environ.get(
294297
"SD_API_KEY",
295-
('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMW0'
296-
'iLCJwZXJtaXNzaW9uX2xldmVsIjozLCJwcm9qZWN0X2lkIjoyMCwiY2xpZW5'
297-
'0X2lkIjoxMH0.xRBHeDxTzYAgFyuU94SWFbjITeoxgyRCQGdIee8qrLA'))
298+
('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vO'
299+
'DFtIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MjQyLCJ'
300+
'jbGllbnRfaWQiOjEwfQ.F-4SC7SREZAu7zo0vdM366kDigYYUBmzCc_EY_THRkg'))
298301

299302
# MODE_TEST give us if you want to use endpoint Test or Prod
300-
MODE_TEST = os.environ.get("MODE_TEST", "test")
301-
endpoint_test = False if MODE_TEST.lower() == 'prod' else True
303+
mode_test = os.environ.get("MODE_TEST", "test")
304+
endpoint_test = False if mode_test.lower() == 'prod' else True
302305
sd_tester = SlicingDiceTester(
303-
api_key=API_KEY,
306+
api_key=api_key,
304307
verbose=False,
305308
endpoint_test=endpoint_test)
306309

0 commit comments

Comments
 (0)