test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
EnablePSetHistory.TestModificationTracking Class Reference
Inheritance diagram for EnablePSetHistory.TestModificationTracking:

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.

555  def setUp(self):
pass
def EnablePSetHistory.TestModificationTracking.testdumpHistory (   self)

Definition at line 650 of file EnablePSetHistory.py.

References popcon_last_value_cfg.Source.

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

References popcon_last_value_cfg.Source.

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

Definition at line 556 of file EnablePSetHistory.py.

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

Definition at line 620 of file EnablePSetHistory.py.

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