CMS 3D CMS Logo

Public Member Functions

EnablePSetHistory::TestModificationTracking Class Reference

List of all members.

Public Member Functions

def setUp
def testdumpHistory
def testModifiedObjectsHistory
def testPSet
def testSeq

Detailed Description

Definition at line 553 of file EnablePSetHistory.py.


Member Function Documentation

def EnablePSetHistory::TestModificationTracking::setUp (   self)

Definition at line 554 of file EnablePSetHistory.py.

00555                        :
            pass
def EnablePSetHistory::TestModificationTracking::testdumpHistory (   self)

Definition at line 650 of file EnablePSetHistory.py.

00651                                  :
00652             process = cms.Process('unittest')
00653             process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
00654             
00655             changeSource(process,"file:filename.root")
00656             self.assertEqual(changeSource._parameters['source'].value,"file:filename.root")
00657             
00658             changeSource(process,"file:filename2.root")
00659             self.assertEqual(changeSource._parameters['source'].value,"file:filename2.root")
00660             
00661             changeSource(process,"file:filename3.root")
00662             self.assertEqual(changeSource._parameters['source'].value,"file:filename3.root")
00663     
00664             self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n")
00665             
00666             process.source.fileNames=cms.untracked.vstring("file:replacedfile.root") 
00667             self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n")
00668             
00669             process.disableRecording()
00670             changeSource.setParameter('source',"file:filename4.root")
00671             action=changeSource.__copy__()
00672             process.addAction(action)
00673             self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n")
00674             
00675             process.enableRecording()
00676             changeSource.setParameter('source',"file:filename5.root")
00677             action=changeSource.__copy__()
00678             process.addAction(action)
00679             process.deleteAction(3)
00680             self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n")
00681 
00682             process.deleteAction(0)
00683             self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n")
            
def EnablePSetHistory::TestModificationTracking::testModifiedObjectsHistory (   self)

Definition at line 684 of file EnablePSetHistory.py.

00685                                             :
00686             process = cms.Process('unittest')
00687             process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
00688             
00689             changeSource(process,"file:filename.root")
00690             self.assertEqual(len(process.history()[0][1]),1)
00691             
00692             process.source.fileNames=cms.untracked.vstring("file:replacedfile.root") 
00693             self.assertEqual(len(process.history()[0][1]),1)
00694             self.assertEqual(len(process.history()[1][1]),1)
00695 
00696             process.source.fileNames=["test2"]
00697             self.assertEqual(len(process.history()[0][1]),1)
00698             self.assertEqual(len(process.history()[1][1]),1)
00699 
00700             changeSource(process,"file:filename2.root")
00701             self.assertEqual(len(process.history()[0][1]),1)
00702             self.assertEqual(len(process.history()[1][1]),1)
00703             self.assertEqual(len(process.history()[2][1]),1)
00704             
00705             process.source.fileNames=cms.untracked.vstring("file:replacedfile2.root") 
00706             self.assertEqual(len(process.history()[0][1]),1)
00707             self.assertEqual(len(process.history()[1][1]),1)
00708             self.assertEqual(len(process.history()[2][1]),1)
00709             self.assertEqual(len(process.history()[3][1]),1)
00710             
    unittest.main()
def EnablePSetHistory::TestModificationTracking::testPSet (   self)

Definition at line 556 of file EnablePSetHistory.py.

00557                           :
00558             ex = cms.EDAnalyzer("Example",
00559                 one = cms.double(0),
00560                 two = cms.bool(True),
00561                 ps = cms.PSet(
00562                     three = cms.int32(10),
00563                     four = cms.string('abc')
00564                 ),
00565                 vps = cms.VPSet(
00566                     cms.PSet(
00567                         five = cms.InputTag('alpha')
00568                     ),
00569                     cms.PSet(
00570                         six = cms.vint32(1,2,3)
00571                     )
00572                 ),
00573                 seven = cms.vstring('alpha','bravo','charlie'),
00574                 eight = cms.vuint32(range(10)),
00575                 nine = cms.int32(0)
00576             )
00577             ex.zero = cms.string('hello')
00578             self.assertEqual(ex._modifications[-1]['name'],'zero')
00579             ex.one = cms.double(1)
00580             ex.one = cms.double(2)
00581             ex.one = cms.double(3)
00582             self.assertEqual(ex._modifications[-1]['name'],'one')
00583             self.assertEqual(ex._modifications[-2]['name'],'one')
00584             self.assertEqual(ex._modifications[-3]['name'],'one')
00585             ex.two = False
00586             self.assertEqual(ex._modifications[-1]['name'],'two')
00587             ex.ps.three.setValue(100) # MISSED
00588             #self.assertEqual(ex.ps._modifications.pop()['name'],'three')
00589             ex.ps.four = 'def'
00590             self.assertEqual(ex.ps._modifications[-1]['name'],'four')
00591             ex.vps[0].five = cms.string('beta')
00592             self.assertEqual(ex.vps[0]._modifications[-1]['name'],'five')
00593             ex.vps[1].__dict__['six'] = cms.vint32(1,4,9) # MISSED
00594             #self.assertEqual(ex.vps[1]._modifications[-1]['name'],'six')
00595             ex.seven[0] = 'delta' # MISSED
00596             #self.assertEqual(ex._modifications[-1]['name'],'seven')
00597             ex.eight.pop() # MISSED
00598             #self.assertEqual(ex._modifications[-1]['name'],'eight')
00599             del ex.nine
00600             #self.assertEqual(ex._modifications[-1]['name'],'nine')
00601             ex.newvpset = cms.VPSet()
00602             self.assertEqual(ex._modifications[-1]['name'],'newvpset')
00603             
00604             process = cms.Process('unittest')
00605             process.ex = ex
00606             mods = process.dumpModifications()
00607             self.assert_('process.ex.zero' in mods)
00608             self.assert_('process.ex.one' in mods)
00609             self.assert_('process.ex.two' in mods)
00610             #self.assert_('process.ex.three' in mods)
00611             self.assert_('process.ex.ps.four' in mods)
00612             self.assert_('process.ex.vps[0].five' in mods)
00613             #self.assert_('process.ex.vps[1].six' in mods)
00614             #self.assert_('process.ex.seven[0]' in mods)
00615             #self.assert_('process.ex.eight' in mods)
00616             self.assert_('process.ex.nine' in mods)
00617             self.assert_('process.ex.newvpset' in mods)
00618             
00619             

def EnablePSetHistory::TestModificationTracking::testSeq (   self)

Definition at line 620 of file EnablePSetHistory.py.

00621                          :
00622             process = cms.Process('unittest')
00623             for i in range(10):
00624               setattr(process,'f%s'%i,cms.EDFilter('f%s'%i))
00625             process.seq1 = cms.Sequence(process.f1*process.f2*process.f3)
00626             self.assertEqual(process.seq1._modifications,[])
00627             process.seq2 = cms.Sequence(process.f4+process.f5+process.f6)
00628             self.assertEqual(process.seq2._modifications,[])
00629             
00630             process.seq1.replace(process.f1,process.f0*process.f1)
00631             self.assertEqual(process.seq1._modifications[-1]['action'],'replace')
00632             
00633             process.seq2.remove(process.f5)
00634             self.assertEqual(process.seq2._modifications[-1]['action'],'remove')
00635             
00636             process.path = cms.Path(process.seq1*process.f7)
00637             self.assertEqual(process.path._modifications,[])
00638             
00639             process.path *= process.seq2
00640             self.assertEqual(process.path._modifications[-1]['action'],'append')
00641             process.path.remove(process.f6)
00642             self.assertEqual(process.path._modifications[-1]['action'],'remove')
00643             process.path.replace(process.f2,~process.f2)
00644             self.assertEqual(process.path._modifications[-1]['action'],'replace')
00645             
00646             mods = process.dumpModifications()
00647             self.assert_('process.seq1' in mods)
00648             self.assert_('process.seq2' in mods)
00649             self.assert_('process.path' in mods)