The DAQ validated the samples-spreadsheet WS payload against its own copy of DataCollectionParameters (aare/common/models.py), which had drifted from the contract: transmission was still an int percent while AareDB now sends a 0-1 fraction (aarecommon 0.7.2), and it still carried five fields that never existed at the beamline. A parity check of all 35 classes in aare/common/models.py against aarecommon 0.7.4 found the ONLY semantic differences inside this class, so it is now imported from aarecommon; everything else in the module stays local (follow-up: fold the rest of aare.common into aarecommon the same way). - aarecommon==0.7.4 added as a dependency (PSI index) - aaredb client 0.1.2a5 -> 0.83.1: the old generated client typed transmission as StrictInt and would reject the fraction payload before the updater even ran; the new one carries the fraction + canonical names (all 11 imported symbols and the 4 SamplesRunner/TellsRunner calls verified) - spreadsheetupdater re-validates aaredb_params through the contract explicitly, so the generated client's copy is transport only - manual_sample_panel builds its DataCollectionParameters from the shared class instead of the generated client's - daq.py read getattr(aaredb_params, 'totalrange'), which is always None on the canonical model (renamed to totalangle years ago) -> the requested total angle never prefilled; fixed Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GPer4T34EcvqVJGpeiEJ4Y
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from aare.common.models import DataCollectionParameters
|
|
|
|
|
|
def test_directory_defaults_when_missing():
|
|
params = DataCollectionParameters()
|
|
assert params.directory is None
|
|
|
|
|
|
def test_directory_blank_defaults_to_macro_path():
|
|
params = DataCollectionParameters(directory="")
|
|
assert params.directory == "{date}/{prefix}"
|
|
|
|
|
|
def test_directory_spaces_are_replaced():
|
|
params = DataCollectionParameters(directory="my folder/run 1")
|
|
assert params.directory == "my_folder/run_1"
|
|
|
|
|
|
def test_directory_rejects_invalid_characters():
|
|
with pytest.raises(ValidationError):
|
|
DataCollectionParameters(directory="bad|path")
|
|
|
|
|
|
def test_exposure_accepts_values_above_1_after_refactor():
|
|
params = DataCollectionParameters(exposure=1.5)
|
|
assert params.exposure == 1.5
|
|
|
|
|
|
def test_cloud_blank_defaults_to_true():
|
|
params = DataCollectionParameters(cloud="")
|
|
assert params.cloud is True
|
|
|
|
|
|
def test_directory_accepts_valid_macros():
|
|
params = DataCollectionParameters(directory="{date}/{prefix}/run")
|
|
assert params.directory == "{date}/{prefix}/run"
|
|
|
|
|
|
|
|
def test_processingpipeline_accepts_unknown_value_after_refactor():
|
|
params = DataCollectionParameters(processingpipeline="xia2")
|
|
assert params.processingpipeline == "xia2"
|
|
|
|
|
|
def test_datacollectionparameters_accepts_legacy_aliases():
|
|
params = DataCollectionParameters(
|
|
totalrange=180,
|
|
cellparameters="10 20 30 90 90 120",
|
|
userresolution=1.4,
|
|
)
|
|
assert params.totalangle == 180
|
|
assert params.unitcell == "10 20 30 90 90 120"
|
|
assert params.processingresolution == 1.4
|
|
|
|
|
|
def test_datacollectionparameters_accepts_new_fields():
|
|
params = DataCollectionParameters(
|
|
totalangle=90,
|
|
unitcell="11,22,33,90,90,120",
|
|
processingresolution=1.2,
|
|
pdbmodel="model.pdb",
|
|
cloud=False,
|
|
)
|
|
assert params.totalangle == 90
|
|
assert params.unitcell == "11,22,33,90,90,120"
|
|
assert params.processingresolution == 1.2
|
|
assert params.pdbmodel == "model.pdb"
|
|
assert params.cloud is False |