Skip to content

Commit 68cc822

Browse files
committed
unit test for backend closure
1 parent 1143838 commit 68cc822

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/unit/test_thrift_backend.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,8 +1406,12 @@ def test_op_handle_respected_in_close_command(self, tcli_service_class):
14061406
)
14071407

14081408
@patch("databricks.sql.backend.thrift_backend.TCLIService.Client", autospec=True)
1409-
def test_session_handle_respected_in_close_session(self, tcli_service_class):
1409+
@patch("databricks.sql.auth.thrift_http_client.THttpClient", autospec=True)
1410+
def test_session_handle_respected_in_close_session(
1411+
self, mock_http_client_class, tcli_service_class
1412+
):
14101413
tcli_service_instance = tcli_service_class.return_value
1414+
mock_http_client_instance = mock_http_client_class.return_value
14111415
thrift_backend = ThriftDatabricksClient(
14121416
"foobar",
14131417
443,
@@ -1416,12 +1420,16 @@ def test_session_handle_respected_in_close_session(self, tcli_service_class):
14161420
auth_provider=AuthProvider(),
14171421
ssl_options=SSLOptions(),
14181422
)
1423+
# Manually set the mocked transport instance
1424+
thrift_backend._transport = mock_http_client_instance
1425+
14191426
session_id = SessionId.from_thrift_handle(self.session_handle)
14201427
thrift_backend.close_session(session_id)
14211428
self.assertEqual(
14221429
tcli_service_instance.CloseSession.call_args[0][0].sessionHandle,
14231430
self.session_handle,
14241431
)
1432+
mock_http_client_instance.close.assert_called_once()
14251433

14261434
@patch("databricks.sql.backend.thrift_backend.TCLIService.Client", autospec=True)
14271435
def test_non_arrow_non_column_based_set_triggers_exception(

0 commit comments

Comments
 (0)