add test for _create_missing_gti()
@@ -38,6 +38,24 @@ def test_data_store_observation(data_store):
assert_skycoord_allclose(obs.target_radec, c)
+@requires_data("gammapy-extra")
+def test_create_missing_gti():
+ """Test the DataStoreObservation._create_missing_gti() method.
+
+ For the 'hess-dl3-dr1' data set, the GTI tables contain only the 'TSTART' and 'TSTOP' from the 'event list' and
+ 'obs index' header. The `DataStoreObservation._create_missing_gti()` method creates a GTI table on-the-fly using
+ exactly those values.
+ """
+ ds = data_store()
+ obs_time_1 = ds.obs(20136).observation_time_duration
+
+ ds = data_store() # DataStore saves some lazyproperties when accessing a hdu location -> we create a new one
+ ds.hdu_table.remove_row(1) # Remove reference to GTI table -> GTI table will be created on-the-fly
+ obs_time_2 = ds.obs(20136).observation_time_duration
+
+ assert obs_time_1 == obs_time_2
+
+
@requires_data("gammapy-extra")
def test_data_store_observation_to_observation_cta(data_store):
"""Test the DataStoreObservation.to_observation_cta conversion method"""
