@@ -148,8 +148,21 @@ def test_log_event():
148148 },
149149 )
150150
151- assert mock_logger .info .call_count == 1
152- assert "key=foo value=bar" in mock_logger .info .call_args [0 ]
151+ mock_logger .log .assert_called_once_with (logging .INFO , "key=foo value=bar" )
152+
153+
154+ def test_log_event_when_debug_log_level ():
155+ with mock .patch ("logging.Logger" ) as mock_logger :
156+ log .log_event (
157+ mock_logger ,
158+ {
159+ "key" : "foo" ,
160+ "value" : "bar" ,
161+ },
162+ log_level = logging .DEBUG ,
163+ )
164+
165+ mock_logger .log .assert_called_once_with (logging .DEBUG , "key=foo value=bar" )
153166
154167
155168def test_modular_input_start ():
@@ -159,10 +172,8 @@ def test_modular_input_start():
159172 "modular_input_name" ,
160173 )
161174
162- assert mock_logger .info .call_count == 1
163- assert (
164- "action=started modular_input_name=modular_input_name"
165- in mock_logger .info .call_args [0 ]
175+ mock_logger .log .assert_called_once_with (
176+ logging .INFO , "action=started modular_input_name=modular_input_name"
166177 )
167178
168179
@@ -173,19 +184,16 @@ def test_modular_input_end():
173184 "modular_input_name" ,
174185 )
175186
176- assert mock_logger .info .call_count == 1
177- assert (
178- "action=ended modular_input_name=modular_input_name"
179- in mock_logger .info .call_args [0 ]
187+ mock_logger .log .assert_called_once_with (
188+ logging .INFO , "action=ended modular_input_name=modular_input_name"
180189 )
181190
182191
183192def test_events_ingested ():
184193 with mock .patch ("logging.Logger" ) as mock_logger :
185194 log .events_ingested (mock_logger , "modular_input_name" , "sourcetype" , 5 )
186195
187- assert mock_logger .info .call_count == 1
188- assert (
189- "action=events_ingested modular_input_name=modular_input_name sourcetype=sourcetype n_events=5"
190- in mock_logger .info .call_args [0 ]
196+ mock_logger .log .assert_called_once_with (
197+ logging .INFO ,
198+ "action=events_ingested modular_input_name=modular_input_name sourcetype=sourcetype n_events=5" ,
191199 )
0 commit comments