@@ -190,28 +190,13 @@ def cli_runner():
190190 return CliRunner ()
191191
192192
193- @pytest .fixture
194- def mock_logging (mocker ):
195- return mocker .patch ("your_cli_module.structlog.get_logger" )
196-
197-
198- @pytest .fixture
199- def mock_setup_logging (mocker ):
200- return mocker .patch ("your_cli_module.setup_logging" )
201-
202-
203193def test_serve_default_options (cli_runner ):
204194 """Test serve command with default options."""
205195 # Use patches for run_servers and logging setup
206196 with (
207197 patch ("src.codegate.cli.run_servers" ) as mock_run ,
208- patch ("src.codegate.cli.structlog.get_logger" ) as mock_logging ,
209198 patch ("src.codegate.cli.setup_logging" ) as mock_setup_logging ,
210199 ):
211-
212- logger_instance = MagicMock ()
213- mock_logging .return_value = logger_instance
214-
215200 # Invoke the CLI command
216201 result = cli_runner .invoke (cli , ["serve" ])
217202
@@ -221,9 +206,6 @@ def test_serve_default_options(cli_runner):
221206 # Check if the logging setup was called with expected defaults
222207 mock_setup_logging .assert_called_once_with (LogLevel .INFO , LogFormat .JSON )
223208
224- # Check if logging was done correctly
225- mock_logging .assert_called_with ("codegate" )
226-
227209 # Validate run_servers was called once
228210 mock_run .assert_called_once ()
229211
@@ -232,13 +214,8 @@ def test_serve_custom_options(cli_runner):
232214 """Test serve command with custom options."""
233215 with (
234216 patch ("src.codegate.cli.run_servers" ) as mock_run ,
235- patch ("src.codegate.cli.structlog.get_logger" ) as mock_logging ,
236217 patch ("src.codegate.cli.setup_logging" ) as mock_setup_logging ,
237218 ):
238-
239- logger_instance = MagicMock ()
240- mock_logging .return_value = logger_instance
241-
242219 # Invoke the CLI command with custom options
243220 result = cli_runner .invoke (
244221 cli ,
@@ -271,9 +248,6 @@ def test_serve_custom_options(cli_runner):
271248 # Assert logging setup was called with the provided log level and format
272249 mock_setup_logging .assert_called_once_with (LogLevel .DEBUG , LogFormat .TEXT )
273250
274- # Assert logger got called with the expected module name
275- mock_logging .assert_called_with ("codegate" )
276-
277251 # Validate run_servers was called once
278252 mock_run .assert_called_once ()
279253 # Retrieve the actual Config object passed to run_servers
@@ -332,20 +306,14 @@ def test_serve_with_config_file(cli_runner, temp_config_file):
332306 """Test serve command with config file."""
333307 with (
334308 patch ("src.codegate.cli.run_servers" ) as mock_run ,
335- patch ("src.codegate.cli.structlog.get_logger" ) as mock_logging ,
336309 patch ("src.codegate.cli.setup_logging" ) as mock_setup_logging ,
337310 ):
338-
339- logger_instance = MagicMock ()
340- mock_logging .return_value = logger_instance
341-
342311 # Invoke the CLI command with the configuration file
343312 result = cli_runner .invoke (cli , ["serve" , "--config" , str (temp_config_file )])
344313
345314 # Assertions to ensure the CLI ran successfully
346315 assert result .exit_code == 0
347316 mock_setup_logging .assert_called_once_with (LogLevel .DEBUG , LogFormat .JSON )
348- mock_logging .assert_called_with ("codegate" )
349317
350318 # Validate that run_servers was called with the expected configuration
351319 mock_run .assert_called_once ()
@@ -380,13 +348,8 @@ def test_serve_priority_resolution(cli_runner: CliRunner, temp_config_file: Path
380348 with (
381349 patch .dict (os .environ , {"LOG_LEVEL" : "INFO" , "PORT" : "9999" }, clear = True ),
382350 patch ("src.codegate.cli.run_servers" ) as mock_run ,
383- patch ("src.codegate.cli.structlog.get_logger" ) as mock_logging ,
384351 patch ("src.codegate.cli.setup_logging" ) as mock_setup_logging ,
385352 ):
386- # Set up mock logger
387- logger_instance = MagicMock ()
388- mock_logging .return_value = logger_instance
389-
390353 # Execute CLI command with specific options overriding environment and config file settings
391354 result = cli_runner .invoke (
392355 cli ,
@@ -420,7 +383,6 @@ def test_serve_priority_resolution(cli_runner: CliRunner, temp_config_file: Path
420383
421384 # Ensure logging setup was called with the highest priority settings (CLI arguments)
422385 mock_setup_logging .assert_called_once_with ("ERROR" , "TEXT" )
423- mock_logging .assert_called_with ("codegate" )
424386
425387 # Verify that the run_servers was called with the overridden settings
426388 config_arg = mock_run .call_args [0 ][0 ] # Assuming Config is the first positional arg
@@ -448,13 +410,8 @@ def test_serve_certificate_options(cli_runner: CliRunner) -> None:
448410 """Test serve command with certificate options."""
449411 with (
450412 patch ("src.codegate.cli.run_servers" ) as mock_run ,
451- patch ("src.codegate.cli.structlog.get_logger" ) as mock_logging ,
452413 patch ("src.codegate.cli.setup_logging" ) as mock_setup_logging ,
453414 ):
454- # Set up mock logger
455- logger_instance = MagicMock ()
456- mock_logging .return_value = logger_instance
457-
458415 # Execute CLI command with certificate options
459416 result = cli_runner .invoke (
460417 cli ,
@@ -478,7 +435,6 @@ def test_serve_certificate_options(cli_runner: CliRunner) -> None:
478435
479436 # Ensure logging setup was called with expected arguments
480437 mock_setup_logging .assert_called_once_with ("INFO" , "JSON" )
481- mock_logging .assert_called_with ("codegate" )
482438
483439 # Verify that run_servers was called with the provided certificate options
484440 config_arg = mock_run .call_args [0 ][0 ] # Assuming Config is the first positional arg
0 commit comments