Skip to content

Commit 3547dd3

Browse files
committed
statistics->counters
1 parent 9dc874d commit 3547dd3

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

docs/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Session API
3232
.. autoclass:: neo4j.v1.ResultSummary
3333
:members:
3434

35-
.. autoclass:: neo4j.v1.StatementStatistics
35+
.. autoclass:: neo4j.v1.Counters
3636
:members:
3737

3838

neo4j/v1/exceptions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(self, data):
4040
setattr(self, key, value)
4141

4242

43-
class DriverError(Exception):
44-
""" Raised when the driver is used incorrectly.
43+
class ResultError(Exception):
44+
""" Raised when the cursor encounters a problem.
4545
"""
4646

4747
pass

neo4j/v1/session.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class which can be used to obtain `Driver` instances that are used for
3232

3333
from .compat import integer, string, urlparse
3434
from .connection import connect, Response, RUN, PULL_ALL
35-
from .exceptions import CypherError, DriverError
35+
from .exceptions import CypherError, ResultError
3636
from .typesystem import hydrated
3737

3838

@@ -222,12 +222,12 @@ def summary(self):
222222
Attempting to access the summary before then will raise an error.
223223
224224
:rtype: ResultSummary
225-
:raises DriverError: if the entire result has not yet been consumed
225+
:raises ResultError: if the entire result has not yet been consumed
226226
"""
227227
if self._consumed:
228228
return self._summary
229229
else:
230-
raise DriverError("Summary not available until the entire result has been consumed")
230+
raise ResultError("Summary not available until the entire result has been consumed")
231231

232232
def _consume(self):
233233
# Consume the remainder of this result, triggering all appropriate callback functions.
@@ -267,8 +267,8 @@ class ResultSummary(object):
267267
#: The type of statement (``'r'`` = read-only, ``'rw'`` = read/write).
268268
statement_type = None
269269

270-
#: A set of statistical information held in a :class:`.StatementStatistics` instance.
271-
statistics = None
270+
#: A set of statistical information held in a :class:`.Counters` instance.
271+
counters = None
272272

273273
#: A :class:`.Plan` instance
274274
plan = None
@@ -286,7 +286,7 @@ def __init__(self, statement, parameters, **metadata):
286286
self.statement = statement
287287
self.parameters = parameters
288288
self.statement_type = metadata.get("type")
289-
self.statistics = StatementStatistics(metadata.get("stats", {}))
289+
self.counters = Counters(metadata.get("stats", {}))
290290
if "plan" in metadata:
291291
self.plan = make_plan(metadata["plan"])
292292
if "profile" in metadata:
@@ -301,7 +301,7 @@ def __init__(self, statement, parameters, **metadata):
301301
notification["description"], position))
302302

303303

304-
class StatementStatistics(object):
304+
class Counters(object):
305305
""" Set of statistics from a Cypher statement execution.
306306
"""
307307

test/test_session.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from unittest import TestCase
2323

2424
from mock import patch
25-
from neo4j.v1.exceptions import DriverError
25+
from neo4j.v1.exceptions import ResultError
2626
from neo4j.v1.session import GraphDatabase, CypherError, Record, record
2727
from neo4j.v1.typesystem import Node, Relationship, Path
2828

@@ -216,12 +216,12 @@ def test_can_obtain_summary_after_consuming_result(self):
216216
assert summary.statement == "CREATE (n) RETURN n"
217217
assert summary.parameters == {}
218218
assert summary.statement_type == "rw"
219-
assert summary.statistics.nodes_created == 1
219+
assert summary.counters.nodes_created == 1
220220

221221
def test_cannot_obtain_summary_without_consuming_result(self):
222222
with GraphDatabase.driver("bolt://localhost").session() as session:
223223
cursor = session.run("CREATE (n) RETURN n")
224-
with self.assertRaises(DriverError):
224+
with self.assertRaises(ResultError):
225225
_ = cursor.summary()
226226

227227
# def test_can_obtain_summary_immediately_if_empty_result(self):
@@ -231,7 +231,7 @@ def test_cannot_obtain_summary_without_consuming_result(self):
231231
# assert summary.statement == "CREATE (n)"
232232
# assert summary.parameters == {}
233233
# assert summary.statement_type == "rw"
234-
# assert summary.statistics.nodes_created == 1
234+
# assert summary.counters.nodes_created == 1
235235

236236
def test_no_plan_info(self):
237237
with GraphDatabase.driver("bolt://localhost").session() as session:

0 commit comments

Comments
 (0)