44 lines
1.3 KiB
Python
44 lines
1.3 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 == None
|
|
#TODO What should the defaults be? Do we want it to be "{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_must_be_between_0_and_1():
|
|
with pytest.raises(ValidationError):
|
|
DataCollectionParameters(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_aperture_accepts_float_string():
|
|
params = DataCollectionParameters(aperture="2.0")
|
|
assert params.aperture == 2
|
|
|
|
|
|
def test_processingpipeline_rejects_unknown_value():
|
|
with pytest.raises(ValidationError):
|
|
DataCollectionParameters(processingpipeline="xia2") |