CMS 3D CMS Logo

List of all members | Public Member Functions
EnablePSetHistory.TestModificationTracking Class Reference
Inheritance diagram for EnablePSetHistory.TestModificationTracking:

Public Member Functions

def setUp (self)
 
def testdumpHistory (self)
 
def testModifiedObjectsHistory (self)
 
def testPSet (self)
 
def testSeq (self)
 

Detailed Description

Definition at line 557 of file EnablePSetHistory.py.

Member Function Documentation

def EnablePSetHistory.TestModificationTracking.setUp (   self)

Definition at line 558 of file EnablePSetHistory.py.

def EnablePSetHistory.TestModificationTracking.testdumpHistory (   self)

Definition at line 654 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

654  def testdumpHistory(self):
655  process = cms.Process('unittest')
656  process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
657 
658  changeSource(process,"file:filename.root")
659  self.assertEqual(changeSource._parameters['source'].value,"file:filename.root")
660 
661  changeSource(process,"file:filename2.root")
662  self.assertEqual(changeSource._parameters['source'].value,"file:filename2.root")
663 
664  changeSource(process,"file:filename3.root")
665  self.assertEqual(changeSource._parameters['source'].value,"file:filename3.root")
666 
667  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")
668 
669  process.source.fileNames=cms.untracked.vstring("file:replacedfile.root")
670  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")
671 
672  process.disableRecording()
673  changeSource.setParameter('source',"file:filename4.root")
674  action=changeSource.__copy__()
675  process.addAction(action)
676  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")
677 
678  process.enableRecording()
679  changeSource.setParameter('source',"file:filename5.root")
680  action=changeSource.__copy__()
681  process.addAction(action)
682  process.deleteAction(3)
683  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")
684 
685  process.deleteAction(0)
686  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")
687 
def EnablePSetHistory.TestModificationTracking.testModifiedObjectsHistory (   self)

Definition at line 688 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

689  process = cms.Process('unittest')
690  process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root"))
691 
692  changeSource(process,"file:filename.root")
693  self.assertEqual(len(process.history()[0][1]),1)
694 
695  process.source.fileNames=cms.untracked.vstring("file:replacedfile.root")
696  self.assertEqual(len(process.history()[0][1]),1)
697  self.assertEqual(len(process.history()[1][1]),1)
698 
699  process.source.fileNames=["test2"]
700  self.assertEqual(len(process.history()[0][1]),1)
701  self.assertEqual(len(process.history()[1][1]),1)
702 
703  changeSource(process,"file:filename2.root")
704  self.assertEqual(len(process.history()[0][1]),1)
705  self.assertEqual(len(process.history()[1][1]),1)
706  self.assertEqual(len(process.history()[2][1]),1)
707 
708  process.source.fileNames=cms.untracked.vstring("file:replacedfile2.root")
709  self.assertEqual(len(process.history()[0][1]),1)
710  self.assertEqual(len(process.history()[1][1]),1)
711  self.assertEqual(len(process.history()[2][1]),1)
712  self.assertEqual(len(process.history()[3][1]),1)
713 
714  unittest.main()
def EnablePSetHistory.TestModificationTracking.testPSet (   self)

Definition at line 560 of file EnablePSetHistory.py.

560  def testPSet(self):
561  ex = cms.EDAnalyzer("Example",
562  one = cms.double(0),
563  two = cms.bool(True),
564  ps = cms.PSet(
565  three = cms.int32(10),
566  four = cms.string('abc')
567  ),
568  vps = cms.VPSet(
569  cms.PSet(
570  five = cms.InputTag('alpha')
571  ),
572  cms.PSet(
573  six = cms.vint32(1,2,3)
574  )
575  ),
576  seven = cms.vstring('alpha','bravo','charlie'),
577  eight = cms.vuint32(range(10)),
578  nine = cms.int32(0)
579  )
580  ex.zero = cms.string('hello')
581  self.assertEqual(ex._modifications[-1]['name'],'zero')
582  ex.one = cms.double(1)
583  ex.one = cms.double(2)
584  ex.one = cms.double(3)
585  self.assertEqual(ex._modifications[-1]['name'],'one')
586  self.assertEqual(ex._modifications[-2]['name'],'one')
587  self.assertEqual(ex._modifications[-3]['name'],'one')
588  ex.two = False
589  self.assertEqual(ex._modifications[-1]['name'],'two')
590  ex.ps.three.setValue(100) # MISSED
591  #self.assertEqual(ex.ps._modifications.pop()['name'],'three')
592  ex.ps.four = 'def'
593  self.assertEqual(ex.ps._modifications[-1]['name'],'four')
594  ex.vps[0].five = cms.string('beta')
595  self.assertEqual(ex.vps[0]._modifications[-1]['name'],'five')
596  ex.vps[1].__dict__['six'] = cms.vint32(1,4,9) # MISSED
597  #self.assertEqual(ex.vps[1]._modifications[-1]['name'],'six')
598  ex.seven[0] = 'delta' # MISSED
599  #self.assertEqual(ex._modifications[-1]['name'],'seven')
600  ex.eight.pop() # MISSED
601  #self.assertEqual(ex._modifications[-1]['name'],'eight')
602  del ex.nine
603  #self.assertEqual(ex._modifications[-1]['name'],'nine')
604  ex.newvpset = cms.VPSet()
605  self.assertEqual(ex._modifications[-1]['name'],'newvpset')
606 
607  process = cms.Process('unittest')
608  process.ex = ex
609  mods = process.dumpModifications()
610  self.assert_('process.ex.zero' in mods)
611  self.assert_('process.ex.one' in mods)
612  self.assert_('process.ex.two' in mods)
613  #self.assert_('process.ex.three' in mods)
614  self.assert_('process.ex.ps.four' in mods)
615  self.assert_('process.ex.vps[0].five' in mods)
616  #self.assert_('process.ex.vps[1].six' in mods)
617  #self.assert_('process.ex.seven[0]' in mods)
618  #self.assert_('process.ex.eight' in mods)
619  self.assert_('process.ex.nine' in mods)
620  self.assert_('process.ex.newvpset' in mods)
621 
622 
623 
def EnablePSetHistory.TestModificationTracking.testSeq (   self)

Definition at line 624 of file EnablePSetHistory.py.

624  def testSeq(self):
625  process = cms.Process('unittest')
626  for i in range(10):
627  setattr(process,'f%s'%i,cms.EDFilter('f%s'%i))
628  process.seq1 = cms.Sequence(process.f1*process.f2*process.f3)
629  self.assertEqual(process.seq1._modifications,[])
630  process.seq2 = cms.Sequence(process.f4+process.f5+process.f6)
631  self.assertEqual(process.seq2._modifications,[])
632 
633  process.seq1.replace(process.f1,process.f0*process.f1)
634  self.assertEqual(process.seq1._modifications[-1]['action'],'replace')
635 
636  process.seq2.remove(process.f5)
637  self.assertEqual(process.seq2._modifications[-1]['action'],'remove')
638 
639  process.path = cms.Path(process.seq1*process.f7)
640  self.assertEqual(process.path._modifications,[])
641 
642  process.path *= process.seq2
643  self.assertEqual(process.path._modifications[-1]['action'],'append')
644  process.path.remove(process.f6)
645  self.assertEqual(process.path._modifications[-1]['action'],'remove')
646  process.path.replace(process.f2,~process.f2)
647  self.assertEqual(process.path._modifications[-1]['action'],'replace')
648 
649  mods = process.dumpModifications()
650  self.assert_('process.seq1' in mods)
651  self.assert_('process.seq2' in mods)
652  self.assert_('process.path' in mods)
653