Skip to content

Commit 819ca6d

Browse files
DvirDukhanswilly22
authored andcommitted
comply to 1.99.7 index response (#62)
1 parent d2f328e commit 819ca6d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

redisgraph/query_result.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class QueryResult(object):
3131
RELATIONSHIPS_DELETED = 'Relationships deleted'
3232
PROPERTIES_SET = 'Properties set'
3333
RELATIONSHIPS_CREATED = 'Relationships created'
34+
INDICES_CREATED = "Indices created"
35+
INDICES_DELETED = "Indices deleted"
3436
INTERNAL_EXECUTION_TIME = 'internal execution time'
3537

3638
def __init__(self, graph, response):
@@ -61,7 +63,8 @@ def parse_statistics(self, raw_statistics):
6163
self.statistics = {}
6264

6365
stats = [self.LABELS_ADDED, self.NODES_CREATED, self.PROPERTIES_SET, self.RELATIONSHIPS_CREATED,
64-
self.NODES_DELETED, self.RELATIONSHIPS_DELETED, self.INTERNAL_EXECUTION_TIME]
66+
self.NODES_DELETED, self.RELATIONSHIPS_DELETED, self.INDICES_CREATED, self.INDICES_DELETED,
67+
self.INTERNAL_EXECUTION_TIME]
6568
for s in stats:
6669
v = self._get_value(s, raw_statistics)
6770
if v is not None:
@@ -248,6 +251,14 @@ def relationships_created(self):
248251
def relationships_deleted(self):
249252
return self._get_stat(self.RELATIONSHIPS_DELETED)
250253

254+
@property
255+
def indices_created(self):
256+
return self._get_stat(self.INDICES_CREATED)
257+
258+
@property
259+
def indices_deleted(self):
260+
return self._get_stat(self.INDICES_DELETED)
261+
251262
@property
252263
def run_time_ms(self):
253264
return self._get_stat(self.INTERNAL_EXECUTION_TIME)

test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,24 @@ def test_param(self):
107107
# All done, remove graph.
108108
redis_graph.delete()
109109

110+
def test_index_response(self):
111+
redis_graph = Graph('social', self.r)
112+
113+
result_set = redis_graph.query("CREATE INDEX ON :person(age)")
114+
self.assertEqual(1, result_set.indices_created)
115+
116+
result_set = redis_graph.query("CREATE INDEX ON :person(age)")
117+
self.assertEqual(0, result_set.indices_created)
118+
119+
result_set = redis_graph.query("DROP INDEX ON :person(age)")
120+
self.assertEqual(1, result_set.indices_deleted)
121+
122+
try:
123+
result_set = redis_graph.query("DROP INDEX ON :person(age)")
124+
except redis.exceptions.ResponseError as e:
125+
self.assertEqual(e.__str__(), "Unable to drop index on :person(age): no such index.")
126+
127+
redis_graph.delete()
128+
110129
if __name__ == '__main__':
111130
unittest.main()

0 commit comments

Comments
 (0)