55
66from databricks .sql .telemetry .telemetry_client import (
77 TelemetryClient ,
8- NOOP_TELEMETRY_CLIENT ,
8+ NoopTelemetryClient ,
99 initialize_telemetry_client ,
1010 get_telemetry_client ,
1111 close_telemetry_client ,
3030
3131@pytest .fixture
3232def noop_telemetry_client ():
33- """Fixture for NOOP_TELEMETRY_CLIENT ."""
34- return NOOP_TELEMETRY_CLIENT
33+ """Fixture for NoopTelemetryClient ."""
34+ return NoopTelemetryClient ()
3535
3636
3737@pytest .fixture
@@ -79,7 +79,13 @@ def telemetry_system_reset():
7979
8080
8181class TestNoopTelemetryClient :
82- """Tests for the NOOP_TELEMETRY_CLIENT."""
82+ """Tests for the NoopTelemetryClient."""
83+
84+ def test_singleton (self ):
85+ """Test that NoopTelemetryClient is a singleton."""
86+ client1 = NoopTelemetryClient ()
87+ client2 = NoopTelemetryClient ()
88+ assert client1 is client2
8389
8490 def test_export_initial_telemetry_log (self , noop_telemetry_client ):
8591 """Test that export_initial_telemetry_log does nothing."""
@@ -362,12 +368,12 @@ def test_initialize_telemetry_client_disabled(self, telemetry_system_reset):
362368 )
363369
364370 client = get_telemetry_client (session_id_hex )
365- assert client is NOOP_TELEMETRY_CLIENT
371+ assert isinstance ( client , NoopTelemetryClient )
366372
367373 def test_get_telemetry_client_nonexistent (self , telemetry_system_reset ):
368374 """Test getting a non-existent telemetry client."""
369375 client = get_telemetry_client ("nonexistent-uuid" )
370- assert client is NOOP_TELEMETRY_CLIENT
376+ assert isinstance ( client , NoopTelemetryClient )
371377
372378 def test_close_telemetry_client (self , telemetry_system_reset ):
373379 """Test closing a telemetry client."""
@@ -392,7 +398,7 @@ def test_close_telemetry_client(self, telemetry_system_reset):
392398 client .close .assert_called_once ()
393399
394400 client = get_telemetry_client (session_id_hex )
395- assert client is NOOP_TELEMETRY_CLIENT
401+ assert isinstance ( client , NoopTelemetryClient )
396402
397403 def test_close_telemetry_client_noop (self , telemetry_system_reset ):
398404 """Test closing a no-op telemetry client."""
@@ -405,7 +411,7 @@ def test_close_telemetry_client_noop(self, telemetry_system_reset):
405411 )
406412
407413 client = get_telemetry_client (session_id_hex )
408- assert client is NOOP_TELEMETRY_CLIENT
414+ assert isinstance ( client , NoopTelemetryClient )
409415
410416 client .close = MagicMock ()
411417
@@ -414,7 +420,7 @@ def test_close_telemetry_client_noop(self, telemetry_system_reset):
414420 client .close .assert_called_once ()
415421
416422 client = get_telemetry_client (session_id_hex )
417- assert client is NOOP_TELEMETRY_CLIENT
423+ assert isinstance ( client , NoopTelemetryClient )
418424
419425 @patch ("databricks.sql.telemetry.telemetry_client._handle_unhandled_exception" )
420426 def test_global_exception_hook (self , mock_handle_exception , telemetry_system_reset ):
0 commit comments