test_mci_sim.py 5.78 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
test    
Yan Zhaojun committed
45
        configfile = dir_path+'MCI_inputData/configData/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
49
        print(configfile)
                
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
50
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, 1)
Yan Zhaojun's avatar
test    
Yan Zhaojun committed
51
        
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
52
        self.assertEqual(
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
53
            1 , 1,
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
54
            "case 1: EXDF sim passes.",
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
55
        )
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    #############################################
    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
74
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
75
76
77
78
79
80
81
        # 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
82
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
        configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config'
      
        sourcein = 'STAR'
        print(configfile)
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, 1)
        
        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
102

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
103
104
105
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
106

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
        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 = dir_path+'MCI_inputData/configData/mci_all_9K.config'
      
        sourcein = 'BIAS'
        print(configfile)
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, 1)
        
        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
140

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
141
142
143
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
144

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
145
146
147
148
149
150
        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
151
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
152
153
154
155
156
157
158
        # 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
159
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
160
161
162
163
164
165
        configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config'
      
        sourcein = 'DARK'
        print(configfile)
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, 1)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
166
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
167
168
169
170
        self.assertEqual(
            1 , 1,
            "case 4: DARK sim passes.",
        ) 
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
171
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
172
173
    #########################################################
    def test_mci_sim_5(self):
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
174
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
175
176
177
178
        """
        Aim
        ---
        Test mci sim function: FLAT case.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
179

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
180
181
182
        Criteria
        --------
        Pass if the demo function returns `1`.
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
183

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
184
185
186
187
188
189
        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
190
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
191
192
193
194
195
196
197
        # 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
198
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
199
200
201
202
203
        configfile = dir_path+'MCI_inputData/configData/mci_all_9K.config'      
        sourcein = 'FLAT'
        print(configfile)
                
        csst_mci_sim.runMCIsim(sourcein,  configfile, dir_path, 1)
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
204
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
205
206
207
208
        self.assertEqual(
            1 , 1,
            "case 5: FLAT sim passes.",
        )
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
209
210
        
        
Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
211
############################################################################
Yan Zhaojun's avatar
update  
Yan Zhaojun committed
212

Yan Zhaojun's avatar
debug    
Yan Zhaojun committed
213