ATLAS Offline Software
Loading...
Searching...
No Matches
python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties Class Reference
Inheritance diagram for python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties:
Collaboration diagram for python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties:

Public Member Functions

 test_substitution_rewrites_algorithm_and_private_tool (self)
 test_substitution_is_idempotent (self)
 test_no_matching_substitution_leaves_properties_unchanged (self)
 test_empty_substitutions_leaves_properties_unchanged (self)

Static Public Attributes

list SUBS = [('AnaJets_STEP3', 'AnaJets')]

Protected Member Functions

 _makeAlg (self)

Detailed Description

Build real configurables via the dual-use interface — the same
primitives `ConfigAccumulator` uses internally — and verify the
substitution walks into algorithm properties and a private tool.

Definition at line 118 of file ConfigPropertySubstitution_unitTest.py.

Member Function Documentation

◆ _makeAlg()

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties._makeAlg ( self)
protected

Definition at line 125 of file ConfigPropertySubstitution_unitTest.py.

125 def _makeAlg (self) :
126 import AnaAlgorithm.DualUseConfig as DualUseConfig
127 alg = DualUseConfig.createAlgorithm (
128 'CP::AsgSelectionAlg', 'TestSelectionAlg')
129 DualUseConfig.addPrivateTool (
130 alg, 'selectionTool', 'CP::AsgFlagSelectionTool')
131 alg.particles = 'AnaJets_STEP3_%SYS%'
132 alg.preselection = 'preselect_STEP3,as_char'
133 alg.selectionDecoration = 'pass_AnaJets_STEP3,as_char'
134 alg.selectionTool.selectionFlags = [
135 'AnaJets_STEP3.flag',
136 'MyAnaJets_STEP3.flag',
137 'unrelated',
138 ]
139 return alg
140

◆ test_empty_substitutions_leaves_properties_unchanged()

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties.test_empty_substitutions_leaves_properties_unchanged ( self)

Definition at line 177 of file ConfigPropertySubstitution_unitTest.py.

177 def test_empty_substitutions_leaves_properties_unchanged (self) :
178 alg = self._makeAlg()
179 before_particles = alg.particles
180 before_flags = list (alg.selectionTool.selectionFlags)
181 substituteComponentProperties (alg, [])
182 self.assertEqual (alg.particles, before_particles)
183 self.assertEqual (list (alg.selectionTool.selectionFlags), before_flags)
184
185

◆ test_no_matching_substitution_leaves_properties_unchanged()

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties.test_no_matching_substitution_leaves_properties_unchanged ( self)

Definition at line 165 of file ConfigPropertySubstitution_unitTest.py.

165 def test_no_matching_substitution_leaves_properties_unchanged (self) :
166 alg = self._makeAlg()
167 before_particles = alg.particles
168 before_preselection = alg.preselection
169 before_decoration = alg.selectionDecoration
170 before_flags = list (alg.selectionTool.selectionFlags)
171 substituteComponentProperties (alg, [('NonExistentContainer', 'Foo')])
172 self.assertEqual (alg.particles, before_particles)
173 self.assertEqual (alg.preselection, before_preselection)
174 self.assertEqual (alg.selectionDecoration, before_decoration)
175 self.assertEqual (list (alg.selectionTool.selectionFlags), before_flags)
176

◆ test_substitution_is_idempotent()

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties.test_substitution_is_idempotent ( self)

Definition at line 156 of file ConfigPropertySubstitution_unitTest.py.

156 def test_substitution_is_idempotent (self) :
157 alg = self._makeAlg()
158 substituteComponentProperties (alg, self.SUBS)
159 before_particles = alg.particles
160 before_flags = list (alg.selectionTool.selectionFlags)
161 substituteComponentProperties (alg, self.SUBS)
162 self.assertEqual (alg.particles, before_particles)
163 self.assertEqual (list (alg.selectionTool.selectionFlags), before_flags)
164

◆ test_substitution_rewrites_algorithm_and_private_tool()

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties.test_substitution_rewrites_algorithm_and_private_tool ( self)

Definition at line 141 of file ConfigPropertySubstitution_unitTest.py.

141 def test_substitution_rewrites_algorithm_and_private_tool (self) :
142 alg = self._makeAlg()
143 substituteComponentProperties (alg, self.SUBS)
144
145 # algorithm-level properties
146 self.assertEqual (alg.particles, 'AnaJets_%SYS%')
147 self.assertEqual (alg.preselection, 'preselect_STEP3,as_char')
148 self.assertEqual (alg.selectionDecoration, 'pass_AnaJets_STEP3,as_char')
149
150 # private-tool vector<string> property
151 self.assertEqual (list (alg.selectionTool.selectionFlags),
152 ['AnaJets.flag',
153 'MyAnaJets_STEP3.flag',
154 'unrelated'])
155

Member Data Documentation

◆ SUBS

python.ConfigPropertySubstitution_unitTest.TestSubstituteComponentProperties.SUBS = [('AnaJets_STEP3', 'AnaJets')]
static

Definition at line 123 of file ConfigPropertySubstitution_unitTest.py.


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