Merge branch 'scans_folder_bugfix' into 'v3'
Bugfix, stop saving scans into log folder See merge request openflexure/openflexure-microscope-server!460
This commit is contained in:
commit
dcf5b26c06
2 changed files with 42 additions and 1 deletions
|
|
@ -175,5 +175,5 @@ def _full_config_from_args(args: Namespace) -> tuple[ThingServerConfig, dict[str
|
|||
internal_config["log_folder"] = log_folder
|
||||
scans_folder = _get_scans_dir(patched_config)
|
||||
if scans_folder is not None:
|
||||
internal_config["log_folder"] = log_folder
|
||||
internal_config["scans_folder"] = scans_folder
|
||||
return ThingServerConfig(**patched_config), internal_config
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
from argparse import Namespace
|
||||
from copy import deepcopy
|
||||
|
||||
import pytest
|
||||
|
||||
from labthings_fastapi.server.config_model import ThingServerConfig
|
||||
|
||||
# Import as ofm server to attempt to minimise confusion with server as a var in other
|
||||
# functions and also FastAPI `Server`.
|
||||
from openflexure_microscope_server import server as ofm_server
|
||||
|
|
@ -127,3 +130,41 @@ def test_get_scans_dir_bad_smart_scan_config():
|
|||
# Creates an Error
|
||||
with pytest.raises(RuntimeError):
|
||||
ofm_server._get_scans_dir(broken_config)
|
||||
|
||||
|
||||
def test_full_config_from_args_json():
|
||||
"""Check that _full_config_from_args returns as expected if json is supplied."""
|
||||
args = Namespace(
|
||||
config=None,
|
||||
json='{"things":{"example": "labthings_fastapi.example_things:MyThing"}}',
|
||||
)
|
||||
lt_conf, ofm_conf = ofm_server._full_config_from_args(args)
|
||||
# If json is supplied OFM config is default. As the json is passed dircectly to
|
||||
# The Pydantic Mocel in LabThings. No custom data allowed.
|
||||
assert isinstance(lt_conf, ThingServerConfig)
|
||||
assert "log_folder" in ofm_conf
|
||||
assert ofm_conf["log_folder"] == "./openflexure/logs"
|
||||
assert "scans_folder" in ofm_conf
|
||||
assert ofm_conf["scans_folder"] is None
|
||||
|
||||
|
||||
def test_full_config_from_args_full(mocker):
|
||||
"""Check that _full_config_from_args returns as expected if json is supplied."""
|
||||
# Mock picamera library so LabThings can create its model.
|
||||
mocker.patch.dict(
|
||||
"sys.modules",
|
||||
{
|
||||
"picamera2": mocker.MagicMock(),
|
||||
"picamera2.encoders": mocker.Mock(),
|
||||
"picamera2.outputs": mocker.Mock(),
|
||||
},
|
||||
)
|
||||
args = Namespace(config=FULL_CONFIG, json=None)
|
||||
lt_conf, ofm_conf = ofm_server._full_config_from_args(args)
|
||||
# If json is supplied OFM config is default. As the json is passed dircectly to
|
||||
# The Pydantic Mocel in LabThings. No custom data allowed.
|
||||
assert isinstance(lt_conf, ThingServerConfig)
|
||||
assert "log_folder" in ofm_conf
|
||||
assert ofm_conf["log_folder"] == "/var/openflexure/logs/"
|
||||
assert "scans_folder" in ofm_conf
|
||||
assert ofm_conf["scans_folder"] == "/var/openflexure/scans/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue