"""Integration tests for the ID09 TXS processing."""

from ...bliss_globals import setup_globals
from .. import testing
from ..processors.id09 import DemoTxsProcessor
from .utils import xrpd


@testing.integration_fixture
def txs_processor(gc_collect):
    xrpd_processor = DemoTxsProcessor()
    xrpd_processor.enable()
    xrpd_processor._plotter.clear_lima_plots(xrpd_processor.detector)
    yield xrpd_processor
    xrpd_processor.disable()


def id09_demo(expo=0.2, npoints=10):
    test_id09_ct_with_1d_integration(expo=expo)
    test_id09_scan_with_1d_integration(expo=expo, npoints=npoints)


@testing.integration_test
def test_id09_ct_with_1d_integration(
    debug_flint, txs_processor, nrepeats: int = None, expo=0.2
):
    xrpd.test_xrpd_ct_with_1d_integration(
        txs_processor,
        [setup_globals.difflab6, setup_globals.diode1, setup_globals.diode2],
        nrepeats=nrepeats,
        expo=expo,
    )


@testing.integration_test
def test_id09_scan_with_1d_integration(
    debug_flint, txs_processor, nrepeats: int = None, expo=0.2, npoints=10
):
    xrpd.test_xrpd_scan_with_1d_integration(
        [txs_processor],
        [
            setup_globals.difflab6,
            setup_globals.diode1,
            setup_globals.diode2,
        ],
        nrepeats=nrepeats,
        expo=expo,
        npoints=npoints,
    )
