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 556 of file EnablePSetHistory.py.

Member Function Documentation

def EnablePSetHistory.TestModificationTracking.setUp (   self)

Definition at line 557 of file EnablePSetHistory.py.

def EnablePSetHistory.TestModificationTracking.testdumpHistory (   self)

Definition at line 653 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

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

Definition at line 687 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

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

Definition at line 559 of file EnablePSetHistory.py.

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

Definition at line 623 of file EnablePSetHistory.py.

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