Skip to content

Commit 104264a

Browse files
committed
Move test into correct file
1 parent dab8645 commit 104264a

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

tests/test_cli_debug.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/test_logs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import labthings_fastapi as lt
2121
from labthings_fastapi.exceptions import LogConfigurationError
2222
from labthings_fastapi.testing import create_thing_without_server
23+
from labthings_fastapi.server.cli import serve_from_cli
2324

2425
from .temp_client import poll_task
2526

@@ -168,6 +169,34 @@ def test_configure_thing_logger():
168169
assert len(dest) == 1
169170
assert dest[0].msg == "Test"
170171

172+
def test_cli_debug_flag():
173+
"""
174+
Test that using the --debug flag sets the logger level to DEBUG,
175+
and that not using it leaves the logger level at INFO.
176+
"""
177+
# Reset logger level to NOTSET
178+
reset_thing_logger()
179+
180+
# Then configure it
181+
logs.configure_thing_logger()
182+
183+
# Run without --debug
184+
# We use dry_run=True to avoid starting uvicorn
185+
# We need a dummy config
186+
dummy_json = '{"things": {}}'
187+
serve_from_cli(["--json", dummy_json], dry_run=True)
188+
189+
assert logs.THING_LOGGER.level == logging.INFO
190+
191+
reset_thing_logger()
192+
193+
# Run with --debug
194+
serve_from_cli(["--json", dummy_json, "--debug"], dry_run=True)
195+
196+
assert logs.THING_LOGGER.level == logging.DEBUG
197+
198+
reset_thing_logger()
199+
171200

172201
def test_add_thing_log_destination():
173202
"""Check the module-level function to add an invocation log destination."""

0 commit comments

Comments
 (0)