@@ -66,7 +66,7 @@ def set_up(file_path, is_diagnostics_enabled=True):
6666 ).start ()
6767
6868
69- def check_file_for_messages (agent_initialized_successfully , file_path , reason = None ):
69+ def check_file_for_messages (agent_initialized_successfully , file_path , reason = None , sdk_present = None ):
7070 with open (file_path , "r" ) as f :
7171 f .seek (0 )
7272 json = loads (f .readline ())
@@ -81,6 +81,10 @@ def check_file_for_messages(agent_initialized_successfully, file_path, reason=No
8181 assert json ["Reason" ] == reason
8282 else :
8383 assert "Reason" not in json
84+ if sdk_present :
85+ assert json ["SDKPresent" ] == sdk_present
86+ else :
87+ assert "SDKPresent" not in json
8488 assert not f .read ()
8589
8690
@@ -110,6 +114,12 @@ def test_log_status_no_reason(self, temp_file_path):
110114 AzureStatusLogger .log_status (True )
111115 check_file_for_messages (True , temp_file_path )
112116
117+ def test_log_status_sdk_present (self , temp_file_path ):
118+ set_up (temp_file_path , is_diagnostics_enabled = True )
119+ AzureStatusLogger .log_status (True , reason = MESSAGE1 )
120+ AzureStatusLogger .log_status (False , reason = MESSAGE2 , sdk_present = True )
121+ check_file_for_messages (agent_initialized_successfully = False , file_path = temp_file_path , reason = MESSAGE2 , sdk_present = True )
122+
113123 def test_disabled_log_status_success (self , temp_file_path ):
114124 set_up (temp_file_path , is_diagnostics_enabled = False )
115125 AzureStatusLogger .log_status (False , MESSAGE1 )
@@ -128,6 +138,12 @@ def test_disabled_log_status_no_reason(self, temp_file_path):
128138 AzureStatusLogger .log_status (True )
129139 check_file_is_empty (temp_file_path )
130140
141+ def test_disabled_log_status_sdk_present (self , temp_file_path ):
142+ set_up (temp_file_path , is_diagnostics_enabled = False )
143+ AzureStatusLogger .log_status (True , reason = MESSAGE1 )
144+ AzureStatusLogger .log_status (False , reason = MESSAGE2 , sdk_present = True )
145+ check_file_is_empty (temp_file_path )
146+
131147 @patch (
132148 "azure.monitor.opentelemetry._diagnostics.status_logger._MACHINE_NAME" ,
133149 TEST_MACHINE_NAME ,
0 commit comments