Skip to content

Commit 73a54af

Browse files
committed
test(connection, transfer-protocol): modify conversion functions when server version < client requests
1 parent 2dacbb8 commit 73a54af

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/integration/test_connection.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99

1010
import pytest # type: ignore
11+
from pytest_mock import mocker
1112

1213
import redshift_connector
1314
from redshift_connector import DriverInfo
@@ -211,6 +212,18 @@ def test_client_protocol_version_invalid_logs(db_kwargs, caplog):
211212
)
212213

213214

215+
def test_client_protocol_version_too_large_is_lowered(db_kwargs, mocker):
216+
db_kwargs["client_protocol_version"] = max(ClientProtocolVersion.list()) + 1
217+
del db_kwargs["region"]
218+
del db_kwargs["cluster_identifier"]
219+
spy = mocker.spy(redshift_connector.Connection, "_enable_protocol_based_conversion_funcs")
220+
with redshift_connector.Connection(**db_kwargs) as con:
221+
act_client_protocol: int = con._client_protocol_version
222+
assert act_client_protocol < db_kwargs["client_protocol_version"]
223+
assert spy.called
224+
assert spy.call_count >= 2 # initial call, additional call when server responds with a lower version
225+
226+
214227
def test_stl_connection_log_contains_driver_version(db_kwargs):
215228
with redshift_connector.connect(**db_kwargs) as conn:
216229
with conn.cursor() as cursor:

0 commit comments

Comments
 (0)