From 12f3271968e1a58cf9b600282d250e1f6ab28414 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Bayle <j2b.bayle@gmail.com>
Date: Tue, 21 Feb 2023 15:45:46 +0100
Subject: [PATCH] Add unit test for initial telemetry size

---
 tests/test_instrument.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/test_instrument.py b/tests/test_instrument.py
index 148506f..6373126 100755
--- a/tests/test_instrument.py
+++ b/tests/test_instrument.py
@@ -3,6 +3,7 @@
 # pylint: disable=missing-module-docstring
 
 import pytest
+import h5py
 from lisainstrument import Instrument
 
 
@@ -74,3 +75,27 @@ def test_locking():
         Instrument(size=100, lock='N7-12')
     with pytest.raises(ValueError):
         Instrument(size=100, lock='N1-67')
+
+def test_initial_telemetry_size():
+    """Test that simulations can run with a nonzero initial telemetry size."""
+
+    orbit_paths = [
+        'tests/keplerian-orbits-1-0-2.h5',
+        'tests/esa-orbits-1-0-2.h5',
+        'tests/keplerian-orbits-2-0.h5',
+        'tests/esa-trailing-orbits-2-0.h5',
+    ]
+
+    for orbit_path in orbit_paths:
+
+        # Read orbit file t0 and leave room for initial telemetry
+        with h5py.File(orbit_path, 'r') as orbitf:
+            t0 = orbitf.attrs['t0'] + 1E6
+        instru = Instrument(
+            initial_telemetry_size=10,
+            telemetry_downsampling=100,
+            orbits=orbit_path,
+            size=100,
+            t0=t0)
+        instru.simulate()
+        instru.write(mode='w')
-- 
GitLab