Merge branch 'v3' into labthings-debug-logging-config
This commit is contained in:
commit
c3ad127f1c
19 changed files with 183 additions and 185 deletions
|
|
@ -15,7 +15,8 @@ from .test_server_config import SIM_CONFIG
|
|||
|
||||
def test_no_config():
|
||||
"""Check that an error is thrown if no configuration is set for the microspe via CLI."""
|
||||
with pytest.raises(RuntimeError, match="No configuration"):
|
||||
msg = "OpenFlexure Microscope Server must have a configuration file specified."
|
||||
with pytest.raises(RuntimeError, match=msg):
|
||||
ofm_server.serve_from_cli([])
|
||||
|
||||
|
||||
|
|
@ -35,6 +36,8 @@ def test_successful_start(mocker, caplog):
|
|||
"openflexure_microscope_server.server.lt.ThingServer.from_config",
|
||||
return_value=mock_server,
|
||||
)
|
||||
# Also mock configure_logging or it will touch a load of code and log.
|
||||
mock_log_configure = mocker.patch.object(ofm_server, "configure_logging")
|
||||
# Also mock customisation or it will try to access the hard drive and make files.
|
||||
mock_customise = mocker.patch.object(ofm_server, "customise_server")
|
||||
# And mock uvicorn.run as we don't want to start a server process
|
||||
|
|
@ -43,7 +46,9 @@ def test_successful_start(mocker, caplog):
|
|||
# Run the mock CLI
|
||||
ofm_server.serve_from_cli(["-c", SIM_CONFIG])
|
||||
|
||||
# Check that the server was customised and the run
|
||||
# Check that the logging was configures, the server was customised, and uvicorn was
|
||||
# run
|
||||
assert mock_log_configure.call_count == 1
|
||||
assert mock_customise.call_count == 1
|
||||
assert mock_uvicorn_run.call_count == 1
|
||||
# Read the log config that was set
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue