test_data_manager.py 2.68 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
"""
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
9
    2022-09-29, Bo Zhang, added test for CsstMbiDataManager
BO ZHANG's avatar
BO ZHANG committed
10
"""
11
import os
BO ZHANG's avatar
BO ZHANG committed
12
import unittest
BO ZHANG's avatar
BO ZHANG committed
13
from csst_common.data_manager import CsstMbiDataManager, CsstMsDataManager
14
from csst_common.params import CSST_PARAMS as CP
BO ZHANG's avatar
BO ZHANG committed
15

BO ZHANG's avatar
BO ZHANG committed
16

BO ZHANG's avatar
BO ZHANG committed
17
18
# deprecated in some days
class TestCsstMbiDataManager(unittest.TestCase):
19
20
21
22
    def setUp(self) -> None:
        self.dm = CsstMbiDataManager.quickstart(ver_sim="C5.2", dir_l1=".", exposure_id=100)

    def test_l0data_existence(self):
BO ZHANG's avatar
BO ZHANG committed
23
        self.assertTrue(self.dm.available_detectors == CP["mbi"]["detectors"])
24
25
26
27
28
29
30
31
        self.assertTrue(os.path.exists(self.dm.l0_detector(6)))
        self.assertTrue(os.path.exists(self.dm.l0_log(6)))
        self.assertTrue(os.path.exists(self.dm.l0_cat(6)))
        self.assertTrue(os.path.exists(self.dm.l0_crs(6)))
        self.assertTrue(isinstance(self.dm.l1_detector(6, post="img.fits"), str))
        self.assertTrue(isinstance(self.dm.l1_file(name="some_file.ext", comment="a demo file"), str))


BO ZHANG's avatar
BO ZHANG committed
32
33
34
35
class TestCsstMsDataManager(unittest.TestCase):
    def setUp(self) -> None:
        self.dm_mbi = CsstMsDataManager.quickstart(ver_sim="C5.2", datatype="mbi", dir_l1=".", exposure_id=100)
        self.dm_sls = CsstMsDataManager.quickstart(ver_sim="C5.2", datatype="sls", dir_l1=".", exposure_id=100)
BO ZHANG's avatar
BO ZHANG committed
36
37
        self.dm_mbi.set_detectors(detectors=None)
        self.dm_sls.set_detectors(detectors=None)
BO ZHANG's avatar
BO ZHANG committed
38
39
40
41
42
43
44
45
46
47
48
49

    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"])
BO ZHANG's avatar
tweaks    
BO ZHANG committed
50
51
52
53
54
        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))
BO ZHANG's avatar
BO ZHANG committed
55
        self.assertTrue(isinstance(self.dm_sls.l1_file(name="some_file.ext", comment="a demo file"), str))