diff --git a/google/cloud/spanner_dbapi/connection.py b/google/cloud/spanner_dbapi/connection.py index 2e60faecc0..b02d62ea27 100644 --- a/google/cloud/spanner_dbapi/connection.py +++ b/google/cloud/spanner_dbapi/connection.py @@ -712,14 +712,14 @@ def connect( credentials, project=project, client_info=client_info, - route_to_leader_enabled=True, + route_to_leader_enabled=route_to_leader_enabled, ) else: client = spanner.Client( project=project, credentials=credentials, client_info=client_info, - route_to_leader_enabled=True, + route_to_leader_enabled=route_to_leader_enabled, ) else: if project is not None and client.project != project: diff --git a/tests/unit/spanner_dbapi/test_connect.py b/tests/unit/spanner_dbapi/test_connect.py index 86dde73159..30ab3c7a8d 100644 --- a/tests/unit/spanner_dbapi/test_connect.py +++ b/tests/unit/spanner_dbapi/test_connect.py @@ -51,6 +51,12 @@ def test_w_implicit(self, mock_client): self.assertIs(connection.instance, instance) client.instance.assert_called_once_with(INSTANCE) + mock_client.assert_called_once_with( + project=mock.ANY, + credentials=mock.ANY, + client_info=mock.ANY, + route_to_leader_enabled=True, + ) self.assertIs(connection.database, database) instance.database.assert_called_once_with(DATABASE, pool=None) @@ -86,7 +92,7 @@ def test_w_explicit(self, mock_client): project=PROJECT, credentials=credentials, client_info=mock.ANY, - route_to_leader_enabled=True, + route_to_leader_enabled=False, ) client_info = mock_client.call_args_list[0][1]["client_info"] self.assertEqual(client_info.user_agent, USER_AGENT)