import pytest
from extra_data import RunDirectory

from cal_tools.jungfraulib import JungfrauCtrl

# TODO: replace with mocked RAW data as in tests/test_agipdlib.py
JF = JungfrauCtrl(
    run_dc=RunDirectory("/gpfs/exfel/exp/CALLAB/202130/p900203/raw/r9031/"),
    ctrl_src="FXE_XAD_JF1M/DET/CONTROL",
    )


@pytest.mark.parametrize(
    'settings,result',
    [
        ('dynamicgain', 0),
        ('dynamichg0', 1),
        ('fixgain1', 0),
        ('fixgain2', 0),
        ('forceswitchg1', 0),
        ('forceswitchg2', 0),
        ('gain0', 0),
        ('highgain0', 1),
        ],
    )
def test_get_gain_setting(settings, result):
    JF.run_settings = settings
    assert JF.get_gain_setting() == result


@pytest.mark.parametrize(
    'mode,result',
    [
        ('dynamicgain', 0),
        ('dynamichg0', 0),
        ('fixgain1', 1),
        ('fixgain2', 1),
        ('forceswitchg1', 0),
        ('forceswitchg2', 0),
        ('dynamic', 0),
        ('fixg1', 1),
        ('fixg2', 1),
        ],
    )
def test_get_gain_mode(mode, result):
    JF.run_mode = mode
    assert JF.get_gain_mode() == result