""" Identifier: KSC-SJ4-tests/test_data_manager.py Name: test_data_manager.py Description: data manager unit test Author: Bo Zhang Created: 2022-09-13 Modified-History: 2022-09-13, Bo Zhang, created 2022-09-29, Bo Zhang, added test for CsstMbiDataManager 2022-10-28, Bo Zhang, deleted unit test for CsstMsDataManager """ import os import unittest from csst_common.data_manager import CsstMsDataManager from csst_common.params import CSST_PARAMS as CP dir_unittest = "/nfsdata/users/csstpipeline/L1Pipeline/unittests/csst_common" class TestCsstMsDataManager(unittest.TestCase): def setUp(self) -> None: self.dm_mbi = CsstMsDataManager.quickstart( ver_sim="C5.2", datatype="mbi", dir_l1=dir_unittest, exposure_id=100, use_dfs=False, dfs_node="kmust") self.dm_sls = CsstMsDataManager.quickstart( ver_sim="C5.2", datatype="sls", dir_l1=dir_unittest, exposure_id=100, use_dfs=False, dfs_node="kmust") self.dm_mbi.target_detectors = None self.dm_sls.target_detectors = None def test_mbi_data_existence(self): self.assertTrue(self.dm_mbi.available_detectors == CP["mbi"]["detectors"]) self.assertTrue(os.path.exists(self.dm_mbi.l0_detector(6))) self.assertTrue(os.path.exists(self.dm_mbi.l0_log(6))) self.assertTrue(os.path.exists(self.dm_mbi.l0_cat(6))) self.assertTrue(os.path.exists(self.dm_mbi.l0_crs(6))) self.assertTrue(isinstance(self.dm_mbi.l1_detector(6, post="img.fits"), str)) self.assertTrue(isinstance(self.dm_mbi.l1_file(name="some_file.ext", comment="a demo file"), str)) def test_sls_data_existence(self): self.assertTrue(self.dm_sls.available_detectors == CP["sls"]["detectors"]) self.assertTrue(os.path.exists(self.dm_sls.l0_detector(1))) self.assertTrue(os.path.exists(self.dm_sls.l0_log(1))) self.assertTrue(os.path.exists(self.dm_sls.l0_cat(1))) self.assertTrue(os.path.exists(self.dm_sls.l0_crs(1))) self.assertTrue(isinstance(self.dm_sls.l1_detector(1, post="flt.fits"), str)) self.assertTrue(isinstance(self.dm_sls.l1_file(name="some_file.ext", comment="a demo file"), str))