Source code for ewoksxrpd.tests.test_worker

import numpy
import pytest
from packaging.version import Version

from ..pyfai_api import PYFAI_VERSION
from ..tasks.worker import persistent_worker


[docs] def test_worker_demo(): integrate_options = { "method": "no_csr_cython", "nbpt_rad": 4096, "unit": "q_nm^-1", "error_model": "azimuthal", "dist": 0.05, "poni1": 0.1, "poni2": 0.1, "rot1": 0.17453292519943295, "rot2": 0, "rot3": 0, "detector": "Pilatus1M", "detector_config": None, "wavelength": 1.0332016536100021e-10, "integrator_name": "sigma_clip_ng", "extra_options": {"max_iter": 3, "thres": 0}, } # Correct Pilatus1M shape image = numpy.zeros((1043, 981)) # lima-camera-simulator < 1.9.10 does not support odd image # shapes so blissdemo adds a border demo_image = numpy.zeros((1044, 982)) if PYFAI_VERSION >= Version("2025.12.0"): exc_class = RuntimeError else: exc_class = AssertionError with persistent_worker(integrate_options, demo=False) as worker: worker.process(image) with pytest.raises(exc_class): worker.process(demo_image) assert worker.extra_options == integrate_options["extra_options"] with persistent_worker(integrate_options, demo=True) as worker: worker.process(demo_image) with pytest.raises(exc_class): worker.process(image)