Skip to content

Commit e4fbaf2

Browse files
rahuls-dbIsaac
andcommitted
Fix telemetry test mocks to set session.use_kernel
The connection-failure telemetry suppression reads session.use_kernel, but these tests mock Session, so use_kernel was a truthy MagicMock — which suppressed the wrapper failure log and broke test_connection_failure_sends_correct_telemetry_payload. Set use_kernel explicitly on the mock (False for the default Thrift case, True for the kernel case) to reflect production. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Rahul Singhal <rahul.singhal@databricks.com>
1 parent f5aaabb commit e4fbaf2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/unit/test_telemetry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ def test_connection_failure_sends_correct_telemetry_payload(
482482
# Set up the mock to create a session instance first, then make open() fail
483483
mock_session_instance = MagicMock()
484484
mock_session_instance.is_open = False # Ensure cleanup is safe
485+
# Default (Thrift) session: the failure-telemetry suppression reads
486+
# session.use_kernel, so the mock must expose a real bool, not a truthy Mock.
487+
mock_session_instance.use_kernel = False
485488
mock_session_instance.open.side_effect = Exception(error_message)
486489
mock_session.return_value = mock_session_instance
487490

@@ -511,6 +514,8 @@ def test_connection_failure_does_not_send_telemetry_for_kernel(
511514
error_message = "Could not connect to host"
512515
mock_session_instance = MagicMock()
513516
mock_session_instance.is_open = False
517+
# Kernel session: use_kernel is read to suppress the wrapper-side failure log.
518+
mock_session_instance.use_kernel = True
514519
mock_session_instance.open.side_effect = Exception(error_message)
515520
mock_session.return_value = mock_session_instance
516521

0 commit comments

Comments
 (0)