"""Integration tests for the ID22 XRPD processing."""

from ...bliss_globals import setup_globals
from .. import testing
from ..processors.xrpd_id22 import DemoId22XrpdProcessor
from .utils import xrpd


@testing.integration_fixture
def id22_processor():
    xrpd_processor = DemoId22XrpdProcessor()
    xrpd_processor.enable(setup_globals.difflab6)
    xrpd_processor._plotter.clear_lima_plots("difflab6")

    yield xrpd_processor

    xrpd_processor.disable()


def id22_xrpd_demo(expo=0.2, npoints=10):
    test_id22_scan_with_1d_integration(expo=expo, npoints=npoints)


@testing.integration_test
def test_id22_scan_with_1d_integration(
    debug_flint, id22_processor, nrepeats: int = None, expo=0.2, npoints=10
):
    xrpd.test_xrpd_scan_with_1d_integration(
        [id22_processor],
        [
            setup_globals.difflab6,
            setup_globals.diode1,
            setup_globals.diode2,
        ],
        nrepeats=nrepeats,
        expo=expo,
        npoints=npoints,
        plotting_fails=False,  # TODO: plotting of the sum spectrum does not work
    )
