Skip to content

Commit f5cb0a0

Browse files
Merge branch 'bugfix/change-api-key' of github.com:SlicingDice/slicingdice-python2 into bugfix/change-api-key
2 parents b4a8e3b + fc45b9a commit f5cb0a0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests_and_examples/run_query_tests.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
class SlicingDiceTester(object):
3535
per_test_insertion = False
36+
insert_sql_data = False
3637

3738
"""Test orchestration class."""
3839

@@ -67,7 +68,7 @@ def run_tests(self, query_type):
6768
num_tests = len(test_data)
6869

6970
self.per_test_insertion = "insert" in test_data[0]
70-
if not self.per_test_insertion:
71+
if not self.per_test_insertion and self.insert_sql_data:
7172
insertion_data = self.load_test_data(query_type, suffix="_insert")
7273
for insertion in insertion_data:
7374
self.client.insert(insertion)
@@ -368,10 +369,15 @@ def are_equal(expected, result):
368369
return False
369370
del result[index]
370371
return True
371-
372+
elif isinstance(expected, float):
373+
return SlicingDiceTester.float_is_close(expected, result)
372374
else:
373375
return expected == result
374376

377+
@staticmethod
378+
def float_is_close(a, b, rel_tol=1e-09, abs_tol=0.0):
379+
return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
380+
375381
@staticmethod
376382
def indexof(x, result):
377383
for i in range(len(result)):
@@ -396,7 +402,10 @@ def main():
396402
# by enviroment variable
397403
# http://panel.slicingdice.com/docs/#api-details-api-connection-api-keys-demo-key
398404
api_key = os.environ.get(
399-
"SD_API_KEY","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMzU2N20iLCJwZXJtaXNzaW9uX2xldmVsIjozLCJwcm9qZWN0X2lkIjoyMzU2NywiY2xpZW50X2lkIjoxMH0.iv3Xf7GkhQynfus6QynGf285cWljD9KBucJxNtnJqjo")
405+
"SD_API_KEY", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiI"
406+
"xNTIzMDY1ODQyNjU4IiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJ"
407+
"vamVjdF9pZCI6MzA1MDgsImNsaWVudF9pZCI6MjAzfQ.R3oKwcA9"
408+
"XoQcW_QBxcvqUNJS44AqCKjoK2Hz5uBnxmU")
400409

401410
# MODE_TEST give us if you want to use endpoint Test or Prod
402411
sd_tester = SlicingDiceTester(

0 commit comments

Comments
 (0)