Skip to content

Commit d9643f3

Browse files
authored
Merge pull request #1093 from robsdedude/fix/revert-breaking-notifications-polyfill
Revert breaking change in summary.notification introduced in #1060
2 parents 36b8103 + 5c4e60b commit d9643f3

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/neo4j/_work/summary.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _notification_from_status(status: dict) -> dict:
175175

176176
return notification
177177

178-
def _set_notifications(self):
178+
def _set_notifications(self) -> None:
179179
if "notifications" in self.metadata:
180180
notifications = self.metadata["notifications"]
181181
if not isinstance(notifications, list):
@@ -197,7 +197,7 @@ def _set_notifications(self):
197197
continue
198198
notification = self._notification_from_status(status)
199199
notifications.append(notification)
200-
self.notifications = notifications
200+
self.notifications = notifications or None
201201
return
202202

203203
self.notifications = None

testkitbackend/totestkit.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def serialize_notification(n: neo4j.SummaryNotification) -> dict:
6464

6565
def serialize_notifications() -> list[dict] | None:
6666
if summary_.notifications is None:
67-
return None
67+
gql_aware_protocol = summary_.server.protocol_version >= (5, 5)
68+
return [] if gql_aware_protocol else None
6869
return [
6970
serialize_notification(n) for n in summary_.summary_notifications
7071
]

tests/unit/common/work/test_summary.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ def test_no_notification_from_status(raw_status, summary_args_kwargs) -> None:
14651465
summary.summary_notifications
14661466
)
14671467

1468-
assert notifications == []
1468+
assert notifications is None
14691469
assert summary_notifications == []
14701470

14711471

@@ -1736,7 +1736,7 @@ def test_no_notification_from_wrong_type_status(
17361736
notifications = summary.notifications
17371737
summary_notifications = summary.summary_notifications
17381738

1739-
assert notifications == []
1739+
assert notifications is None
17401740
assert summary_notifications == []
17411741

17421742

@@ -1930,7 +1930,7 @@ def test_no_notification_from_status_without_neo4j_code(
19301930
notifications = summary.notifications
19311931
summary_notifications = summary.summary_notifications
19321932

1933-
assert notifications == []
1933+
assert notifications is None
19341934
assert summary_notifications == []
19351935

19361936

@@ -2081,7 +2081,7 @@ def test_notification_from_broken_status(
20812081
summary = ResultSummary(*args, **kwargs)
20822082

20832083
notifications = summary.notifications
2084-
assert notifications == []
2084+
assert notifications is None
20852085

20862086

20872087
def test_notifications_from_statuses_keep_order(

0 commit comments

Comments
 (0)