test_mci_sim.py 7.32 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
    #############################################
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
59
#     def test_mci_sim_2(self):
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
60
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
61
62
63
64
#         """
#         Aim
#         ---
#         Test mci sim function: STAR case.
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
65
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
66
67
68
#         Criteria
#         --------
#         Pass if the demo function returns `1`.
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
69
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
70
71
72
73
74
75
#         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
#         # demo function test
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
#         print(dir_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
80
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
81
82
83
#         # 获取当前工作目录
#         # 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
      
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
87
88
#         sourcein = 'STAR'
#         print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
89
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
90
#         debug=True
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
91
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
92
#         csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
93
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
94
95
96
97
#         self.assertEqual(
#             1 , 1,
#             "case 2: STAR sim passes.",
#         )  
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
98
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
99
100
#     #########################################################
#     def test_mci_sim_3(self):
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
101
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
102
103
104
105
#         """
#         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
#         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
debug    
Yan Zhaojun committed
117
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
118
119
120
#         # demo function test
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
#         print(dir_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
121
 
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
122
123
124
#         # 获取当前工作目录
#         # current_path = os.getcwd()         
#         # print("当前路径:", current_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
125
        
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
      
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
128
129
#         sourcein = 'BIAS'
#         print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
130
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
131
#         debug=True
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
132
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
133
#         csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
134
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
135
136
137
138
139
140
#         self.assertEqual(
#             1 , 1,
#             "case 3: BIAS sim passes.",
#         )
#     #########################################################
#     def test_mci_sim_4(self):
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
141
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
142
143
144
145
#         """
#         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
#         # demo function test
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
#         print(dir_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
161
 
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
162
163
164
#         # 获取当前工作目录
#         # 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
      
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
168
169
#         sourcein = 'DARK'
#         print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
170
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
171
#         debug=True
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
172
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
173
#         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
#         # demo function test
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
#         print(dir_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
202
 
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
203
204
205
#         # 获取当前工作目录
#         # 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
208
209
#         configfile = './csst_mci_sim/mci_data/mci_all_9K.config'      
#         sourcein = 'FLAT'
#         print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
210
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
211
#         debug=True
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
212
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
213
#         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
222
# ############################################################################
#     def test_mci_sim_6(self):
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
223
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
224
225
226
227
#         """
#         Aim
#         ---
#         Test mci sim function: EXDF case.
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
228
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
229
230
231
#         Criteria
#         --------
#         Pass if the demo function returns `1`.
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
232
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
233
234
235
236
237
238
#         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
debug    
Yan Zhaojun committed
239
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
240
241
242
#         # demo function test
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'],'mci_sim/')
#         print(dir_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
243
    
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
244
245
246
#         # 获取当前工作目录
#         # current_path = os.getcwd()         
#         # print("当前路径:", current_path)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
247
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
248
#         configfile = './csst_mci_sim/mci_data/mci_all_9K.config'
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
249
      
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
250
251
#         sourcein = 'STAR'
#         print(configfile)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
252
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
253
#         debug=True
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
254
                
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
255
#         csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, debug, 1)
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
256
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
257
258
259
260
261
#         self.assertEqual(
#             1 , 1,
#             "case 6: STAR sim passes.",
#         )
#     #############################################
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
262

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
263