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

Public Member Functions

 setUp (self)
 
 test_1 (self)
 
 test_2 (self)
 
 test_3 (self)
 
 tearDown (self)
 

Public Attributes

 alg1 = TestAlgo()
 Calibration algorithm for use in unittests.
 
 alg2 = TestAlgo()
 Calibration algorithm for use in unittests.
 
 col1 = b2.register_module('CaTest')
 Collector module attribute for use in unittests.
 
str name = 'TestCalibration'
 Calibration name for use in unittests.
 
 example_file1 = Path("example1.root")
 Path to an example file.
 
 example_file2 = Path("example2.root")
 Path to a second example file.
 

Detailed Description

UnitTest for validity of Calibration class when given arguments of different types

Definition at line 107 of file test_framework.py.

Member Function Documentation

◆ setUp()

setUp ( self)
Create useful objects for each test

Definition at line 112 of file test_framework.py.

112 def setUp(self):
113 """
114 Create useful objects for each test
115 """
116 from ROOT import Belle2 # noqa: make the Belle2 namespace available
117 from ROOT.Belle2 import TestCalibrationAlgorithm as TestAlgo
118
119
120 self.alg1 = TestAlgo()
121
122 self.alg2 = TestAlgo()
123
124 self.col1 = b2.register_module('CaTest')
125
126 self.name = 'TestCalibration'
127
128 self.example_file1 = Path("example1.root")
129
130 self.example_file2 = Path("example2.root")
131 self.example_file1.touch()
132 self.example_file2.touch()
133

◆ tearDown()

tearDown ( self)
Unlink example files

Definition at line 164 of file test_framework.py.

164 def tearDown(self):
165 """
166 Unlink example files
167 """
168 self.example_file1.unlink()
169 self.example_file2.unlink()
170
171

◆ test_1()

test_1 ( self)
Test whether or not calibration is valid with correct setup and if name is stored correctly

Definition at line 134 of file test_framework.py.

134 def test_1(self):
135 """
136 Test whether or not calibration is valid with correct setup and if name is stored correctly
137 """
138 cal = Calibration(
139 self.name,
140 collector=self.col1,
141 algorithms=[
142 self.alg1,
143 self.alg2],
144 input_files=self.example_file2.as_posix())
145 self.assertTrue(cal.is_valid() and cal.name == self.name)
146

◆ test_2()

test_2 ( self)
Test whether or not calibration is valid with alternative correct setup and if name is stored correctly

Definition at line 147 of file test_framework.py.

147 def test_2(self):
148 """
149 Test whether or not calibration is valid with alternative correct setup and if name is stored correctly
150 """
151 cal = Calibration(self.name, 'CaTest', self.alg1, input_files=self.example_file1.as_posix())
152 self.assertTrue(cal.is_valid() and cal.name == self.name)
153

◆ test_3()

test_3 ( self)
Test that the default options are correctly applied to a calibration

Definition at line 154 of file test_framework.py.

154 def test_3(self):
155 """
156 Test that the default options are correctly applied to a calibration
157 """
158 defaults = {"max_iterations": 4}
159 cal1 = Calibration(self.name, collector=self.col1, algorithms=[self.alg1], input_files=self.example_file1.as_posix())
160 cal1._apply_calibration_defaults(defaults)
161 cal2 = Calibration(self.name, collector=self.col1, algorithms=[self.alg1], input_files=self.example_file2.as_posix())
162 self.assertTrue(cal1.max_iterations == 4 and not cal2.max_iterations)
163

Member Data Documentation

◆ alg1

alg1 = TestAlgo()

Calibration algorithm for use in unittests.

Definition at line 120 of file test_framework.py.

◆ alg2

alg2 = TestAlgo()

Calibration algorithm for use in unittests.

Definition at line 122 of file test_framework.py.

◆ col1

col1 = b2.register_module('CaTest')

Collector module attribute for use in unittests.

Definition at line 124 of file test_framework.py.

◆ example_file1

example_file1 = Path("example1.root")

Path to an example file.

Definition at line 128 of file test_framework.py.

◆ example_file2

example_file2 = Path("example2.root")

Path to a second example file.

Definition at line 130 of file test_framework.py.

◆ name

str name = 'TestCalibration'

Calibration name for use in unittests.

Definition at line 126 of file test_framework.py.


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