Skip to content

Commit 499529c

Browse files
committed
Other changes for 4.2 support
1 parent 4b15d2a commit 499529c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

neo4j/io/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ def protocol_handlers(cls, protocol_version=None):
134134

135135
# Carry out Bolt subclass imports locally to avoid circular dependency issues.
136136
from neo4j.io._bolt3 import Bolt3
137-
from neo4j.io._bolt4 import Bolt4x0, Bolt4x1
137+
from neo4j.io._bolt4 import Bolt4x0, Bolt4x1, Bolt4x2
138138

139139
handlers = {
140140
Bolt3.PROTOCOL_VERSION: Bolt3,
141141
Bolt4x0.PROTOCOL_VERSION: Bolt4x0,
142142
Bolt4x1.PROTOCOL_VERSION: Bolt4x1,
143+
Bolt4x2.PROTOCOL_VERSION: Bolt4x2,
143144
}
144145

145146
if protocol_version is None:
@@ -209,6 +210,10 @@ def open(cls, address, *, auth=None, timeout=None, routing_context=None, **pool_
209210
# Carry out Bolt subclass imports locally to avoid circular dependency issues.
210211
from neo4j.io._bolt4 import Bolt4x1
211212
connection = Bolt4x1(address, s, pool_config.max_connection_lifetime, auth=auth, user_agent=pool_config.user_agent, routing_context=routing_context)
213+
elif pool_config.protocol_version == (4, 2):
214+
# Carry out Bolt subclass imports locally to avoid circular dependency issues.
215+
from neo4j.io._bolt4 import Bolt4x2
216+
connection = Bolt4x2(address, s, pool_config.max_connection_lifetime, auth=auth, user_agent=pool_config.user_agent, routing_context=routing_context)
212217
else:
213218
log.debug("[#%04X] S: <CLOSE>", s.getpeername()[1])
214219
s.shutdown(SHUT_RDWR)
@@ -672,7 +677,7 @@ def fetch_routing_info(self, *, address, timeout, database):
672677

673678
# Carry out Bolt subclass imports locally to avoid circular dependency issues.
674679
from neo4j.io._bolt3 import Bolt3
675-
from neo4j.io._bolt4 import Bolt4x0, Bolt4x1
680+
from neo4j.io._bolt4 import Bolt4x0, Bolt4x1, Bolt4x2
676681

677682
from neo4j.api import (
678683
SYSTEM_DATABASE,

tests/unit/io/test_class_bolt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def test_class_method_protocol_handlers():
2929
# python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_protocol_handlers
3030
protocol_handlers = Bolt.protocol_handlers()
31-
assert len(protocol_handlers) == 3
31+
assert len(protocol_handlers) == 4
3232

3333

3434
@pytest.mark.parametrize(
@@ -53,7 +53,7 @@ def test_class_method_protocol_handlers_with_invalid_protocol_version():
5353
def test_class_method_get_handshake():
5454
# python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_get_handshake
5555
handshake = Bolt.get_handshake()
56-
assert handshake == b"\x00\x00\x01\x04\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00\x00"
56+
assert handshake == b"\x00\x00\x02\x04\x00\x00\x01\x04\x00\x00\x00\x04\x00\x00\x00\x03"
5757

5858

5959
def test_magic_preamble():

0 commit comments

Comments
 (0)