test_mci_sim.py 7.03 KB
Newer Older
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
1
"""
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
2
3
4
Identifier:     mci_sim/tests/test_mci_sim.py
Name:           test_mci_sim.py
Description:    Test mci sim.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
5
6
7
8
9
10
11
12
13
14
Author:         Zhaojun Yan
Created:        2024-04-09
Modified-History:
    2024-04-09, Zhaojun Yan, created

"""

import unittest
import os
import sys
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
15
import faulthandler
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
16
from csst_mci_sim import csst_mci_sim
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
17

Yan Zhaojun's avatar
update  
Yan Zhaojun committed
18
class TestDemoFunction(unittest.TestCase):
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
19
    def test_mci_sim_1(self):
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
20
        
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
21
22
23
        """
        Aim
        ---
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
24
        Test mci sim function: EXDF case.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
25
26
27
28
29
30
31
32
33
34

        Criteria
        --------
        Pass if the demo function returns `1`.

        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
35
36
        faulthandler.enable()
        
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
37
        # demo function test
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
38
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
39
        print(dir_path)
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
40
 
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
41
42
43
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
44
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
45
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
46
      
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
47
        sourcein = 'EXDF'
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
48
        print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
49
50
        
        debug=True
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
51
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
52
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
53
        
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
54
        self.assertEqual(
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
55
            1 , 1,
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
56
            "case 1: EXDF sim passes.",
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
57
        )
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    #############################################
    def test_mci_sim_2(self):
        
        """
        Aim
        ---
        Test mci sim function: STAR case.
    
        Criteria
        --------
        Pass if the demo function returns `1`.
    
        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
        faulthandler.enable()
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
76
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
77
78
79
80
81
82
83
        # demo function test
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
        print(dir_path)
    
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
84
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
85
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
86
87
88
89
      
        sourcein = 'STAR'
        print(configfile)
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
90
91
92
        debug=True
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
93
94
95
96
97
98
99
100
101
102
103
104
105
        
        self.assertEqual(
            1 , 1,
            "case 2: STAR sim passes.",
        )  
        
    #########################################################
    def test_mci_sim_3(self):
        
        """
        Aim
        ---
        Test mci sim function: BIAS case.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
106

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
107
108
109
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
110

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
        faulthandler.enable()
        
        # demo function test
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
        print(dir_path)
 
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
126
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
127
128
129
130
      
        sourcein = 'BIAS'
        print(configfile)
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
131
132
133
        debug=True
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
134
135
136
137
138
139
140
141
142
143
144
145
        
        self.assertEqual(
            1 , 1,
            "case 3: BIAS sim passes.",
        )
    #########################################################
    def test_mci_sim_4(self):
        
        """
        Aim
        ---
        Test mci sim function: DARK case.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
146

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
147
148
149
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
150

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
151
152
153
154
155
156
        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
        faulthandler.enable()
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
157
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
158
159
160
161
162
163
164
        # demo function test
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
        print(dir_path)
 
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
165
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
166
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
167
168
169
170
      
        sourcein = 'DARK'
        print(configfile)
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
171
172
173
        debug=True
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
174
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
175
176
177
178
        self.assertEqual(
            1 , 1,
            "case 4: DARK sim passes.",
        ) 
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
179
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
180
181
    #########################################################
    def test_mci_sim_5(self):
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
182
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
183
184
185
186
        """
        Aim
        ---
        Test mci sim function: FLAT case.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
187

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
188
189
190
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
191

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
192
193
194
195
196
197
        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
        faulthandler.enable()
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
198
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
199
200
201
202
203
204
205
        # demo function test
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
        print(dir_path)
 
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
206
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
207
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'      
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
208
209
210
        sourcein = 'FLAT'
        print(configfile)
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
211
212
213
        debug=True
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
214
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
215
216
217
218
        self.assertEqual(
            1 , 1,
            "case 5: FLAT sim passes.",
        )
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
219
220
        
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
221
############################################################################
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
    def test_mci_sim_7(self):
        
        """
        Aim
        ---
        Test mci sim function: EXDF case.
    
        Criteria
        --------
        Pass if the demo function returns `1`.
    
        Details
        -------
        The demo function returns the length of the input argument list.
        This case aims to test whether the demo function returns `1` if input is `None`.
        """
        faulthandler.enable()
        
        # demo function test
        dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
        print(dir_path)
    
        # 获取当前工作目录
        # current_path = os.getcwd()         
        # print("当前路径:", current_path)
        
        configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
      
        sourcein = 'STAR'
        print(configfile)
        
        debug=True
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
        
        self.assertEqual(
            1 , 1,
            "case 7: STAR sim passes.",
        )
    #############################################
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
262

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
263