From 900c9d05e31510bc584f4c1a396e7dd579fef33a Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Thu, 14 Dec 2023 15:27:11 +0000
Subject: [PATCH] Try adding test for missing constant but module 'present'

---
 tests/test_calcat_interface2.py | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/tests/test_calcat_interface2.py b/tests/test_calcat_interface2.py
index 5b3e82b3a..36b42b9d8 100644
--- a/tests/test_calcat_interface2.py
+++ b/tests/test_calcat_interface2.py
@@ -4,6 +4,7 @@ from cal_tools.calcat_interface2 import (
     CalibrationData,
     AGIPDConditions,
     DSSCConditions,
+    LPDConditions,
     SingleConstantVersion,
 )
 
@@ -67,11 +68,27 @@ def test_DSSC_modules_missing():
     )
     # DSSC was used with only 3 quadrants at this point
     modnos = list(range(4)) + list(range(8, 16))
-    assert dssc_cd.aggregator_names == [f'DSSC{m:02}' for m in modnos]
+    assert dssc_cd.aggregator_names == [f"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
-    ]
+    assert dssc_cd.qm_names == [f"Q{(m // 4) + 1}M{(m % 4) + 1}" for m in modnos]
+
+
+@pytest.mark.requires_gpfs
+def test_LPD_constant_missing():
+    lpd_cd = CalibrationData.from_condition(
+        LPDConditions(memory_cells=200, sensor_bias_voltage=250),
+        "FXE_DET_LPD1M-1",
+        event_at="2022-05-22T02:00:00",
+    )
+    # Constants are missing for 1 module (LPD05), but it was still included in
+    # the PDUs for the detector, so it should still appear in the lists.
+    modnos = range(16)
+    assert lpd_cd.aggregator_names == [f"DSSC{m:02}" for m in modnos]
+    assert lpd_cd.module_nums == modnos
+    assert lpd_cd.qm_names == [f"Q{(m // 4) + 1}M{(m % 4) + 1}" for m in modnos]
+
+    assert len(lpd_cd["Offset"].module_nums) == 16
+    assert len(lpd_cd["Offset"].constants) == 15
 
 
 @pytest.mark.xfail
-- 
GitLab