|
34 | 34 | class SlicingDiceTester(object):
|
35 | 35 | """Test orchestration class."""
|
36 | 36 | def __init__(self, api_key, verbose=False, endpoint_test=True):
|
| 37 | + # The Slicing Dice API client |
37 | 38 | self.client = SlicingDice(api_key)
|
38 | 39 | self.endpoint_test = endpoint_test
|
39 | 40 |
|
40 | 41 | # Translation table for fields with timestamp
|
41 | 42 | self.field_translation = {}
|
42 | 43 |
|
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' |
46 | 50 |
|
47 | 51 | self.num_successes = 0
|
48 | 52 | self.num_fails = 0
|
@@ -86,7 +90,8 @@ def run_tests(self, query_type):
|
86 | 90 | print
|
87 | 91 |
|
88 | 92 | 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.""" |
90 | 95 | self.field_translation = {}
|
91 | 96 |
|
92 | 97 | def load_test_data(self, query_type):
|
@@ -170,7 +175,6 @@ def index_data(self, test):
|
170 | 175 | Parameters:
|
171 | 176 | test -- Dictionary containing test name, fields metadata, data to be
|
172 | 177 | indexed, query, and expected results.
|
173 |
| - auto_create -- Auto create a field if not exists. |
174 | 178 | """
|
175 | 179 | is_singular = len(test['index']) == 1
|
176 | 180 | entity_or_entities = 'entity' if is_singular else 'entities'
|
@@ -289,18 +293,17 @@ def main():
|
289 | 293 | # Testing class with demo API key or one of your API key
|
290 | 294 | # by enviroment variable
|
291 | 295 | # 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( |
294 | 297 | "SD_API_KEY",
|
295 |
| - ('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMW0' |
296 |
| - 'iLCJwZXJtaXNzaW9uX2xldmVsIjozLCJwcm9qZWN0X2lkIjoyMCwiY2xpZW5' |
297 |
| - '0X2lkIjoxMH0.xRBHeDxTzYAgFyuU94SWFbjITeoxgyRCQGdIee8qrLA')) |
| 298 | + ('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vO' |
| 299 | + 'DFtIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MjQyLCJ' |
| 300 | + 'jbGllbnRfaWQiOjEwfQ.F-4SC7SREZAu7zo0vdM366kDigYYUBmzCc_EY_THRkg')) |
298 | 301 |
|
299 | 302 | # 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 |
302 | 305 | sd_tester = SlicingDiceTester(
|
303 |
| - api_key=API_KEY, |
| 306 | + api_key=api_key, |
304 | 307 | verbose=False,
|
305 | 308 | endpoint_test=endpoint_test)
|
306 | 309 |
|
|
0 commit comments