ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.CFElements.TestCF Class Reference
Inheritance diagram for python.CFElements.TestCF:
Collaboration diagram for python.CFElements.TestCF:

Public Member Functions

def setUp (self)
 
def test_findTop (self)
 
def test_findDeep (self)
 
def test_findMissing (self)
 
def test_findRespectingScope (self)
 
def test_iterSequences (self)
 
def test_findAlgorithms (self)
 

Public Attributes

 top
 

Detailed Description

Definition at line 221 of file CFElements.py.

Member Function Documentation

◆ setUp()

def python.CFElements.TestCF.setUp (   self)

Definition at line 222 of file CFElements.py.

222  def setUp( self ):
223  import AthenaPython.PyAthena as PyAthena
224 
225  top = parOR("top")
226  top.Members += [parOR("nest1")]
227  nest2 = seqAND("nest2")
228  top.Members += [nest2]
229  top.Members += [PyAthena.Alg("SomeAlg0")]
230  nest2.Members += [parOR("deep_nest1")]
231  nest2.Members += [parOR("deep_nest2")]
232 
233  nest2.Members += [PyAthena.Alg("SomeAlg1")]
234  nest2.Members += [PyAthena.Alg("SomeAlg2")]
235  nest2.Members += [PyAthena.Alg("SomeAlg3")]
236  self.top = top
237 

◆ test_findAlgorithms()

def python.CFElements.TestCF.test_findAlgorithms (   self)

Definition at line 301 of file CFElements.py.

301  def test_findAlgorithms( self ):
302  a1 = findAlgorithm( self.top, "SomeAlg0" )
303  self.assertIsNotNone( a1, "Can't find algorithm present in sequence" )
304 
305  a1 = findAlgorithm( self.top, "SomeAlg1" )
306  self.assertIsNotNone( a1, "Can't find nested algorithm " )
307 
308  nest2 = findSubSequence( self.top, "nest2" )
309 
310  a1 = findAlgorithm( nest2, "SomeAlg0" )
311  self.assertIsNone( a1, "Finding algorithm that is in the upper sequence" )
312 
313  a1 = findAlgorithm( nest2, "NonexistentAlg" )
314  self.assertIsNone( a1, "Finding algorithm that is does not exist" )
315 
316  a1 = findAlgorithm( self.top, "SomeAlg0", 1)
317  self.assertIsNotNone( a1, "Could not find algorithm within the required nesting depth == 1" )
318 
319  a1 = findAlgorithm( self.top, "SomeAlg1", 1)
320  self.assertIsNone( a1, "Could find algorithm even if it is deep in sequences structure" )
321 
322  a1 = findAlgorithm( self.top, "SomeAlg1", 2)
323  self.assertIsNotNone( a1, "Could not find algorithm within the required nesting depth == 2" )
324 
325  a1 = findAlgorithm( self.top, "SomeAlg3", 2)
326  self.assertIsNotNone( a1 is None, "Could find algorithm even if it is deep in sequences structure" )
327 
328 

◆ test_findDeep()

def python.CFElements.TestCF.test_findDeep (   self)

Definition at line 247 of file CFElements.py.

247  def test_findDeep( self ):
248  # deeper search
249  d = findSubSequence( self.top, "deep_nest2")
250  self.assertIsNotNone( d, "Deep searching for sub seqeunce fails" )
251  self.assertEqual( d.getName(), "deep_nest2", "Wrong sub sequence in deep search" )
252 

◆ test_findMissing()

def python.CFElements.TestCF.test_findMissing (   self)

Definition at line 253 of file CFElements.py.

253  def test_findMissing( self ):
254  # algorithm is not a sequence
255  d = findSubSequence( self.top, "SomeAlg1")
256  self.assertIsNone( d, "Algorithm confused as a sequence" )
257 
258  # no on demand creation
259  inexistent = findSubSequence( self.top, "not_there" )
260  self.assertIsNone( inexistent, "ERROR, found sub sequence that does not relay exist" )
261 
262  # owner finding
263  inexistent = findOwningSequence(self.top, "not_there")
264  self.assertIsNone( inexistent, "ERROR, found owner of inexistent sequence " )
265 

◆ test_findRespectingScope()

def python.CFElements.TestCF.test_findRespectingScope (   self)

Definition at line 266 of file CFElements.py.

266  def test_findRespectingScope( self ):
267  owner = findOwningSequence( self.top, "deep_nest1")
268  self.assertEqual( owner.getName(), "nest2", "Wrong owner %s" % owner.getName() )
269 
270  owner = findOwningSequence( self.top, "deep_nest2")
271  self.assertEqual( owner.getName(), "nest2", "Wrong owner %s" % owner.getName() )
272 
273  owner = findOwningSequence( self.top, "SomeAlg1")
274  self.assertEqual( owner.getName(), "nest2", "Wrong owner %s" % owner.getName() )
275 
276  owner = findOwningSequence( self.top, "SomeAlg0")
277  self.assertEqual( owner.getName() , "top", "Wrong owner %s" % owner.getName() )
278 

◆ test_findTop()

def python.CFElements.TestCF.test_findTop (   self)

Definition at line 238 of file CFElements.py.

238  def test_findTop( self ):
239  f = findSubSequence( self.top, "top")
240  self.assertIsNotNone( f, "Can not find sequence at start" )
241  self.assertEqual( f.getName(), "top", "Wrong sequence" )
242  # a one level deep search
243  nest2 = findSubSequence( self.top, "nest2" )
244  self.assertIsNotNone( nest2, "Can not find sub sequence" )
245  self.assertEqual( nest2.getName(), "nest2", "Sub sequence incorrect" )
246 

◆ test_iterSequences()

def python.CFElements.TestCF.test_iterSequences (   self)

Definition at line 279 of file CFElements.py.

279  def test_iterSequences( self ):
280  # Traverse from top
281  result = [seq.getName() for seq in iterSequences( self.top )]
282  self.assertEqual( result, ['top', 'nest1', 'nest2', 'deep_nest1', 'deep_nest2',
283  'SomeAlg1', 'SomeAlg2', 'SomeAlg3', 'SomeAlg0'] )
284 
285  # Traverse from nested sequence
286  nest2 = findSubSequence( self.top, "nest2" )
287  result = [seq.getName() for seq in iterSequences( nest2 )]
288  self.assertEqual( result, ['nest2', 'deep_nest1', 'deep_nest2',
289  'SomeAlg1', 'SomeAlg2', 'SomeAlg3'] )
290 
291  # Traverse empty sequence
292  deep_nest2 = findSubSequence( self.top, "deep_nest2" )
293  result = [seq.getName() for seq in iterSequences( deep_nest2 )]
294  self.assertEqual( result, ['deep_nest2'] )
295 
296  # Traverse from algorithm
297  alg1 = findAlgorithm( self.top, "SomeAlg1" )
298  result = [seq.getName() for seq in iterSequences( alg1 )]
299  self.assertEqual( result, ['SomeAlg1'] )
300 

Member Data Documentation

◆ top

python.CFElements.TestCF.top

Definition at line 236 of file CFElements.py.


The documentation for this class was generated from the following file:
python.CFElements.findOwningSequence
def findOwningSequence(start, nameToLookFor)
Definition: CFElements.py:114
python.CFElements.seqAND
def seqAND(name, subs=[])
Definition: CFElements.py:25
python.CFElements.parOR
def parOR(name, subs=[])
Definition: CFElements.py:15
PyAthena::Alg
Definition: PyAthenaAlg.h:33
python.CFElements.findSubSequence
def findSubSequence(start, nameToLookFor)
Definition: CFElements.py:100
python.CFElements.findAlgorithm
def findAlgorithm(startSequence, nameToLookFor, depth=1000000)
Definition: CFElements.py:145
python.CFElements.iterSequences
def iterSequences(start)
Definition: CFElements.py:206