Skip to content

Commit de358de

Browse files
author
Your Name
committed
Merge remote-tracking branch 'origin/feature/update-tests_and_examples' into feature/updateAPIVocabulary
2 parents 59e0298 + a1de8a6 commit de358de

File tree

3 files changed

+72
-52
lines changed

3 files changed

+72
-52
lines changed

README.md

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ client.insert(insert_data)
5151

5252
# Querying data
5353
query_data = {
54-
"users-between-20-and-40": [
54+
"query-name": "users-between-20-and-40",
55+
"query": [
5556
{
5657
"age": {
5758
"range": [
@@ -304,29 +305,36 @@ Count the number of entities matching the given query. This method corresponds t
304305
```python
305306
from pyslicer import SlicingDice
306307
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
307-
query = {
308-
"corolla-or-fit": [
309-
{
310-
"car-model": {
311-
"equals": "toyota corolla"
312-
}
313-
},
314-
"or",
315-
{
316-
"car-model": {
317-
"equals": "honda fit"
308+
query = [
309+
{
310+
"query-name": "corolla-or-fit",
311+
"query": [
312+
{
313+
"car-model": {
314+
"equals": "toyota corolla"
315+
}
316+
},
317+
"or",
318+
{
319+
"car-model": {
320+
"equals": "honda fit"
321+
}
318322
}
319-
},
320-
],
321-
"ford-ka": [
322-
{
323-
"car-model": {
324-
"equals": "ford ka"
323+
],
324+
"bypass-cache": False
325+
},
326+
{
327+
"query-name": "ford-ka",
328+
"query": [
329+
{
330+
"car-model": {
331+
"equals": "ford ka"
332+
}
325333
}
326-
}
327-
],
328-
"bypass-cache": False
329-
}
334+
],
335+
"bypass-cache": False
336+
}
337+
]
330338
print client.count_entity(query)
331339
```
332340

@@ -351,31 +359,38 @@ Count the number of occurrences for time-series events matching the given query.
351359
```python
352360
from pyslicer import SlicingDice
353361
client = SlicingDice('MASTER_OR_READ_API_KEY', uses_test_endpoint=False)
354-
query = {
355-
"test-drives-in-ny": [
356-
{
357-
"test-drives": {
358-
"equals": "NY",
359-
"between": [
360-
"2016-08-16T00:00:00Z",
361-
"2016-08-18T00:00:00Z"
362-
]
362+
query = [
363+
{
364+
"query-name": "test-drives-in-ny",
365+
"query": [
366+
{
367+
"test-drives": {
368+
"equals": "NY",
369+
"between": [
370+
"2016-08-16T00:00:00Z",
371+
"2016-08-18T00:00:00Z"
372+
]
373+
}
363374
}
364-
}
365-
],
366-
"test-drives-in-ca": [
367-
{
368-
"test-drives": {
369-
"equals": "CA",
370-
"between": [
371-
"2016-04-04T00:00:00Z",
372-
"2016-04-06T00:00:00Z"
373-
]
375+
],
376+
"bypass-cache": True
377+
},
378+
{
379+
"query-name": "test-drives-in-ca",
380+
"query": [
381+
{
382+
"test-drives": {
383+
"equals": "CA",
384+
"between": [
385+
"2016-04-04T00:00:00Z",
386+
"2016-04-06T00:00:00Z"
387+
]
388+
}
374389
}
375-
}
376-
],
377-
"bypass-cache": True
378-
}
390+
],
391+
"bypass-cache": True
392+
}
393+
]
379394
print client.count_event(query)
380395
```
381396

pyslicer/utils/validators.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ def check_dictionary(self, dictionary):
3232
"This query has invalid keys or values.")
3333

3434
for key in dictionary:
35-
dictionary_value = dictionary[key]
35+
if isinstance(key, dict):
36+
dictionary_value = key.get('query')
37+
else:
38+
dictionary_value = dictionary[key]
3639
self.check_dictionary_value(dictionary_value)
3740

3841
def check_list(self, dictionary_list):

tests_and_examples/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Each JSON file contains a list of examples, such as the following excerpt, with
3636
}
3737
},
3838
"query": {
39-
"test_result_query": [
39+
"query-name": "test_result_query",
40+
"query": [
4041
{
4142
"string-test-column": {
4243
"equals": "value:matched_value"
@@ -65,17 +66,18 @@ Each JSON file contains a list of examples, such as the following excerpt, with
6566
],
6667
"insert": {
6768
"1": {
68-
"integer-test-column": "1000001"
69+
"integer-test-column": 1000001
6970
},
7071
"2": {
71-
"integer-test-column": "1234567"
72+
"integer-test-column": 1234567
7273
},
7374
"3": {
74-
"integer-test-column": "1000001"
75-
},
75+
"integer-test-column": 1000001
76+
}
7677
},
7778
"query": {
78-
"test_result_query": [
79+
"query-name": "test_result_query",
80+
"query": [
7981
{
8082
"integer-test-column": {
8183
"equals": 1000001

0 commit comments

Comments
 (0)