diff --git a/tests/test_calcat_interface2.py b/tests/test_calcat_interface2.py index fa0acc1c64a7227e6ef3e0f90fd1098143333bfd..8bdf3a2ac703f3f95fd6027ca7adb10d48b4fee8 100644 --- a/tests/test_calcat_interface2.py +++ b/tests/test_calcat_interface2.py @@ -1,7 +1,10 @@ import pytest from cal_tools.calcat_interface2 import ( - CalibrationData, AGIPDConditions, SingleConstantVersion, + CalibrationData, + AGIPDConditions, + DSSCConditions, + SingleConstantVersion, ) @@ -22,11 +25,11 @@ def test_AGIPD_CalibrationData_metadata(): cond, "MID_DET_AGIPD1M-1", event_at="2022-09-01 13:26:48.00", - calibrations=['Offset', 'SlopesFF'], + calibrations=["Offset", "SlopesFF"], ) - assert 'Offset' in agipd_cd - assert set(agipd_cd['Offset'].constants) == {f'AGIPD{i:02}' for i in range(16)} - assert isinstance(agipd_cd['Offset'].constants['AGIPD00'], SingleConstantVersion) + assert "Offset" in agipd_cd + assert set(agipd_cd["Offset"].constants) == {f"AGIPD{m:02}" for m in range(16)} + assert isinstance(agipd_cd["Offset"].constants["AGIPD00"], SingleConstantVersion) @pytest.mark.requires_gpfs @@ -47,20 +50,36 @@ def test_AGIPD_CalibrationData_metadata_SPB(): event_at="2020-01-07 13:26:48.00", ) assert "Offset" in agipd_cd - assert set(agipd_cd["Offset"].constants) == {f"AGIPD{i:02}" for i in range(16)} + assert set(agipd_cd["Offset"].constants) == {f"AGIPD{m:02}" for m in range(16)} assert agipd_cd["Offset"].module_nums == list(range(16)) assert agipd_cd["Offset"].qm_names == [ - f"Q{(i // 4) + 1}M{(i % 4) + 1}" for i in range(16) + f"Q{(m // 4) + 1}M{(m % 4) + 1}" for m in range(16) ] assert isinstance(agipd_cd["Offset"].constants["AGIPD00"], SingleConstantVersion) +@pytest.mark.requires_gpfs +def test_DSSC_modules_missing(): + dssc_cd = CalibrationData.from_condition( + DSSCConditions(sensor_bias_voltage=100, memory_cells=600), + "SQS_DET_DSSC1M-1", + event_at="2023-11-29 00:00:00", + ) + # DSSC was used with only 3 quadrants at this point + modnos = list(range(4)) + list(range(8, 16)) + assert dssc_cd.aggregator_names == ['DSSC{m:02}' for m in modnos] + assert dssc_cd.module_nums == modnos + assert dssc_cd.qm_names == [ + f"Q{(m // 4) + 1}M{(m % 4) + 1}" for m in modnos + ] + + @pytest.mark.xfail @pytest.mark.requires_gpfs def test_AGIPD_CalibrationData_report(): """Test CalibrationData with data from report""" # Report ID: https://in.xfel.eu/calibration/reports/3757 agipd_cd = CalibrationData.from_report(3757) - assert set(agipd_cd) == {'Offset', 'Noise', 'ThresholdsDark', 'BadPixelsDark'} - assert agipd_cd.aggregator_names == [f'AGIPD{n:02}' for n in range(16)] - assert isinstance(agipd_cd['Offset'].constants['AGIPD00'], SingleConstantVersion) + assert set(agipd_cd) == {"Offset", "Noise", "ThresholdsDark", "BadPixelsDark"} + assert agipd_cd.aggregator_names == [f"AGIPD{n:02}" for n in range(16)] + assert isinstance(agipd_cd["Offset"].constants["AGIPD00"], SingleConstantVersion)