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

Member Function Documentation

def EnablePSetHistory.TestModificationTracking.setUp (   self)

Definition at line 554 of file EnablePSetHistory.py.

def EnablePSetHistory.TestModificationTracking.testdumpHistory (   self)

Definition at line 650 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

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

Definition at line 684 of file EnablePSetHistory.py.

References PFJetToCaloProducer_cfi.Source.

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

Definition at line 556 of file EnablePSetHistory.py.

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

Definition at line 620 of file EnablePSetHistory.py.

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