Fix test_observation CALDB access
# Licensed under a 3-clause BSD style license - see LICENSE.rst
+import os
+from pathlib import Path
import pytest
from ...utils.testing import requires_data
from ...data import DataStore
@@ -140,7 +142,7 @@ class TestDataStoreMaker:
hdu_class = ["events", "gti", "aeff_2d", "edisp_2d", "psf_3gauss", "bkg_3d"]
assert list(self.data_store.hdu_table["HDU_CLASS"]) == 4 * hdu_class
- def test_observation(self):
+ def test_observation(self, monkeypatch):
"""Check that one observation can be accessed OK"""
obs = self.data_store.obs(110380)
assert obs.obs_id == 110380
@@ -148,7 +150,10 @@ class TestDataStoreMaker:
assert obs.events.time[0].iso == "2021-01-21 12:00:03.045"
assert obs.gti.time_start[0].iso == "2021-01-21 12:00:00.000"
- # TODO: set env CALDB = "$GAMMAPY_DATA/cta-1dc/caldb"
+ # Note: IRF access requires the CALDB env var
+ caldb_path = Path(os.environ["GAMMAPY_DATA"]) / Path("cta-1dc/caldb")
+ monkeypatch.setenv("CALDB", str(caldb_path))
+
assert obs.aeff.__class__.__name__ == "EffectiveAreaTable2D"
assert obs.bkg.__class__.__name__ == "Background3D"
assert obs.edisp.__class__.__name__ == "EnergyDispersion2D"
