Belle II Software development
TestCAF Class Reference
Inheritance diagram for TestCAF:

Public Member Functions

 setUp (self)
 
 test_add_calibration (self)
 
 test_add_dependency_on_itself (self)
 
 test_make_output_dir (self)
 
 test_config_output_dir (self)
 
 tearDown (self)
 

Public Attributes

str name1 = 'TestCalibration1'
 Calibration name for use in unittests.
 
str name2 = 'TestCalibration2'
 Calibration name for use in unittests.
 
str name3 = 'TestCalibration3'
 Calibration name for use in unittests.
 
 example_file1 = Path("example1.root")
 Path to an example file.
 
 cal1 = Calibration(self.name1, col, alg, self.example_file1.as_posix())
 Calibration attribute for use in unittests.
 
 cal2 = Calibration(self.name2, col, alg, self.example_file1.as_posix())
 Calibration attribute for use in unittests.
 
 cal3 = Calibration(self.name3, col, alg, self.example_file1.as_posix())
 Calibration attribute for use in unittests.
 

Detailed Description

UnitTest for configuration and simple running of CAF

Definition at line 172 of file test_framework.py.

Member Function Documentation

◆ setUp()

setUp ( self)
Create useful objects for each test and the teardown

Definition at line 177 of file test_framework.py.

177 def setUp(self):
178 """
179 Create useful objects for each test and the teardown
180 """
181 from ROOT import Belle2 # noqa: make the Belle2 namespace available
182 from ROOT.Belle2 import TestCalibrationAlgorithm as TestAlgo
183
184
185 self.name1 = 'TestCalibration1'
186
187 self.name2 = 'TestCalibration2'
188
189 self.name3 = 'TestCalibration3'
190 alg = TestAlgo()
191 col = b2.register_module('CaTest')
192
193 self.example_file1 = Path("example1.root")
194 self.example_file1.touch()
195
196 self.cal1 = Calibration(self.name1, col, alg, self.example_file1.as_posix())
197
198 self.cal2 = Calibration(self.name2, col, alg, self.example_file1.as_posix())
199
200 self.cal3 = Calibration(self.name3, col, alg, self.example_file1.as_posix())
201

◆ tearDown()

tearDown ( self)
Removes files that were created during these tests

Definition at line 234 of file test_framework.py.

234 def tearDown(self):
235 """
236 Removes files that were created during these tests
237 """
238 self.example_file1.unlink()
239 dirs = glob.glob('*testCAF_outputdir')
240 for directory in dirs:
241 shutil.rmtree(directory)
242
243

◆ test_add_calibration()

test_add_calibration ( self)
Test that add_calibration function results in correct output

Definition at line 202 of file test_framework.py.

202 def test_add_calibration(self):
203 """
204 Test that add_calibration function results in correct output
205 """
206 fw = CAF()
207 fw.add_calibration(self.cal1)
208 fw.add_calibration(self.cal2)
209 self.assertTrue(fw.calibrations[self.name1].name == self.name1 and fw.calibrations[self.name2].name == self.name2)
210

◆ test_add_dependency_on_itself()

test_add_dependency_on_itself ( self)
Test that add_dependency function cannot add itself

Definition at line 211 of file test_framework.py.

211 def test_add_dependency_on_itself(self):
212 """
213 Test that add_dependency function cannot add itself
214 """
215 self.cal1.depends_on(self.cal1)
216 self.assertFalse(self.cal1.dependencies)
217

◆ test_config_output_dir()

test_config_output_dir ( self)
Test that config is correctly setting the default output path.

Definition at line 227 of file test_framework.py.

227 def test_config_output_dir(self):
228 """
229 Test that config is correctly setting the default output path.
230 """
231 fw = CAF()
232 self.assertTrue(fw.output_dir == 'calibration_results')
233

◆ test_make_output_dir()

test_make_output_dir ( self)
Test that output_dir directory is created correctly

Definition at line 218 of file test_framework.py.

218 def test_make_output_dir(self):
219 """
220 Test that output_dir directory is created correctly
221 """
222 fw = CAF()
223 fw.output_dir = 'testCAF_outputdir'
224 fw._make_output_dir()
225 self.assertTrue(os.path.isdir('testCAF_outputdir'))
226

Member Data Documentation

◆ cal1

cal1 = Calibration(self.name1, col, alg, self.example_file1.as_posix())

Calibration attribute for use in unittests.

Definition at line 196 of file test_framework.py.

◆ cal2

cal2 = Calibration(self.name2, col, alg, self.example_file1.as_posix())

Calibration attribute for use in unittests.

Definition at line 198 of file test_framework.py.

◆ cal3

cal3 = Calibration(self.name3, col, alg, self.example_file1.as_posix())

Calibration attribute for use in unittests.

Definition at line 200 of file test_framework.py.

◆ example_file1

example_file1 = Path("example1.root")

Path to an example file.

Definition at line 193 of file test_framework.py.

◆ name1

str name1 = 'TestCalibration1'

Calibration name for use in unittests.

Definition at line 185 of file test_framework.py.

◆ name2

str name2 = 'TestCalibration2'

Calibration name for use in unittests.

Definition at line 187 of file test_framework.py.

◆ name3

str name3 = 'TestCalibration3'

Calibration name for use in unittests.

Definition at line 189 of file test_framework.py.


The documentation for this class was generated from the following file: