Skip to content

Commit 80af47e

Browse files
improved test case containing EXPLAIN MATCH query (#397)
The test of notification of a EXPLAIN MATCH is not longer hard coded.
1 parent 272ac3d commit 80af47e

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

neo4j/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"Transaction",
5050
"Result",
5151
"ResultSummary",
52+
"SummaryCounters",
53+
"Plan",
54+
"ProfiledPlan",
55+
"Notification",
56+
"Position",
5257
"Query",
5358
"Session",
5459
"unit_of_work",
@@ -105,6 +110,11 @@
105110
)
106111
from neo4j.work.summary import (
107112
ResultSummary,
113+
SummaryCounters,
114+
Plan,
115+
ProfiledPlan,
116+
Notification,
117+
Position,
108118
)
109119

110120

tests/integration/test_summary.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020

2121
import pytest
2222

23+
from neo4j import (
24+
ResultSummary,
25+
SummaryCounters,
26+
Plan,
27+
ProfiledPlan,
28+
Notification,
29+
Position,
30+
)
31+
32+
2333
def get_operator_type(op):
2434
# Fabric will suffix with db name, remove this to handle fabric on/off
2535
op = op.split("@")
@@ -72,28 +82,22 @@ def test_no_notification_info(session):
7282

7383

7484
def test_can_obtain_notification_info(session):
85+
# python -m pytest tests/integration/test_summary.py -s -v -k test_can_obtain_notification_info
7586
result = session.run("EXPLAIN MATCH (n), (m) RETURN n, m")
7687
summary = result.consume()
77-
notifications = summary.notifications
88+
assert isinstance(summary, ResultSummary)
7889

90+
notifications = summary.notifications
91+
assert isinstance(notifications, list)
7992
assert len(notifications) == 1
93+
8094
notification = notifications[0]
81-
assert notification.code == "Neo.ClientNotification.Statement.CartesianProductWarning"
82-
assert notification.title == "This query builds a cartesian product between " \
83-
"disconnected patterns."
84-
assert notification.severity == "WARNING"
85-
assert notification.description == "If a part of a query contains multiple " \
86-
"disconnected patterns, this will build a " \
87-
"cartesian product between all those parts. This " \
88-
"may produce a large amount of data and slow down " \
89-
"query processing. While occasionally intended, " \
90-
"it may often be possible to reformulate the " \
91-
"query that avoids the use of this cross product, " \
92-
"perhaps by adding a relationship between the " \
93-
"different parts or by using OPTIONAL MATCH " \
94-
"(identifier is: (m))"
95-
position = notification.position
96-
assert position
95+
assert isinstance(notification, Notification)
96+
assert notification.code.startswith("Neo.ClientNotification") # "Neo.ClientNotification.Statement.CartesianProductWarning"
97+
assert isinstance(notification.title, str) # "This query builds a cartesian product between disconnected patterns."
98+
assert isinstance(notification.severity, str) # "WARNING"
99+
assert isinstance(notification.description, str)
100+
assert isinstance(notification.position, Position)
97101

98102

99103
def test_contains_time_information(session):

0 commit comments

Comments
 (0)