Source code for ewoksmx.tests.models.test_xds_background_image_model

import pytest
from esrf_pathlib import ESRFPath
from pydantic import ValidationError

from ewoksmx.tasks.characterisation.xds_background_image import InputModel
from ewoksmx.tasks.characterisation.xds_background_image import OutputModel


[docs] def test_xds_background_image_input_valid(test_metadata): """Test that a valid InputModel is created correctly.""" path = ESRFPath("/tmp/test_file.h5") input_model = InputModel(aggregated_hdf5_path=path, metadata=test_metadata) assert isinstance(input_model.aggregated_hdf5_path, ESRFPath) assert input_model.aggregated_hdf5_path == path
[docs] def test_xds_background_image_missing_required_fields(): """Test that missing fields raise a ValidationError.""" with pytest.raises(ValidationError): # Missing metadata InputModel(aggregated_hdf5_path="/tmp/test.h5")
[docs] def test_xds_background_image_invalid_path_type(): """Test that invalid types for path raise errors if ESRFPath enforces it.""" with pytest.raises(ValidationError): # Providing an integer instead of a path/string InputModel(aggregated_hdf5_path=12345, metadata={})
[docs] def test_xds_background_image_valid_output(test_metadata): """Test that a valid OutputModel is created correctly.""" # Mocking data for XDSBackgroundImageModel bkginit_cbf_path = ESRFPath("/tmp/BKGINIT.CBF") model = OutputModel(xds_background_path=bkginit_cbf_path, metadata=test_metadata) assert model is not None
[docs] def test_xds_background_image_output_validation_error(): """Test that incorrect structure in OutputModel raises error.""" with pytest.raises(ValidationError): # xds_background is missing OutputModel(metadata={"test": "data"})