33
33
34
34
class SlicingDiceTester (object ):
35
35
"""Test orchestration class."""
36
- def __init__ (self , api_key , verbose = False ):
36
+ def __init__ (self , api_key , verbose = False , endpoint_test = True ):
37
37
self .client = SlicingDice (api_key )
38
+ self .endpoint_test = endpoint_test
38
39
39
40
# Translation table for fields with timestamp
40
41
self .field_translation = {}
@@ -179,7 +180,7 @@ def index_data(self, test):
179
180
if self .verbose :
180
181
print ' - {}' .format (index_data )
181
182
182
- self .client .index (index_data , test = True )
183
+ self .client .index (index_data , test = self . endpoint_test )
183
184
184
185
# Wait a few seconds so the data can be indexed by SlicingDice
185
186
time .sleep (self .sleep_time )
@@ -200,13 +201,17 @@ def execute_query(self, query_type, test):
200
201
print ' - {}' .format (query_data )
201
202
202
203
if query_type == 'count_entity' :
203
- result = self .client .count_entity (query_data , test = True )
204
+ result = self .client .count_entity (
205
+ query_data , test = self .endpoint_test )
204
206
elif query_type == 'count_event' :
205
- result = self .client .count_event (query_data , test = True )
207
+ result = self .client .count_event (
208
+ query_data , test = self .endpoint_test )
206
209
elif query_type == 'top_values' :
207
- result = self .client .top_values (query_data , test = True )
210
+ result = self .client .top_values (
211
+ query_data , test = self .endpoint_test )
208
212
elif query_type == 'aggregation' :
209
- result = self .client .aggregation (query_data , test = True )
213
+ result = self .client .aggregation (
214
+ query_data , test = self .endpoint_test )
210
215
211
216
return result
212
217
@@ -275,9 +280,14 @@ def main():
275
280
('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMW0'
276
281
'iLCJwZXJtaXNzaW9uX2xldmVsIjozLCJwcm9qZWN0X2lkIjoyMCwiY2xpZW5'
277
282
'0X2lkIjoxMH0.xRBHeDxTzYAgFyuU94SWFbjITeoxgyRCQGdIee8qrLA' ))
283
+
284
+ # MODE_TEST give us if you want to use endpoint Test or Prod
285
+ MODE_TEST = os .environ .get ("MODE_TEST" )
286
+ endpoint_test = False if MODE_TEST .lower () == 'prod' else True
278
287
sd_tester = SlicingDiceTester (
279
288
api_key = API_KEY ,
280
- verbose = False )
289
+ verbose = False ,
290
+ endpoint_test = endpoint_test )
281
291
282
292
try :
283
293
for query_type in query_types :
0 commit comments