CMS 3D CMS Logo

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

Public Member Functions

def testMassReplaceInputTag
 
def testMassReplaceParam
 
def testMassSearchReplaceAnyInputTag
 
def testMassSearchReplaceParam
 

Detailed Description

Definition at line 154 of file MassReplace.py.

Member Function Documentation

def MassReplace.TestModuleCommand.testMassReplaceInputTag (   self)

Definition at line 214 of file MassReplace.py.

References ConfigBuilder.dumpPython(), and MassReplace.massReplaceInputTag().

215  def testMassReplaceInputTag(self):
216  process1 = cms.Process("test")
217  massReplaceInputTag(process1, "a", "b", False, False, False)
218  self.assertEqual(process1.dumpPython(), cms.Process('test').dumpPython())
219  p = cms.Process("test")
220  p.a = cms.EDProducer("a", src=cms.InputTag("gen"))
221  p.b = cms.EDProducer("ab", src=cms.InputTag("a"))
222  p.c = cms.EDProducer("ac", src=cms.InputTag("b"),
223  nested = cms.PSet(src = cms.InputTag("a"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("a")),
224  nestedv = cms.VPSet(cms.PSet(src = cms.InputTag("a")), cms.PSet(src = cms.InputTag("d"))),
225  unestedv = cms.untracked.VPSet(cms.untracked.PSet(src = cms.InputTag("a")), cms.untracked.PSet(src = cms.InputTag("d"))),
226  vec = cms.VInputTag(cms.InputTag("a"), cms.InputTag("b"), cms.InputTag("c"), cms.InputTag("d")),
227  uvec = cms.untracked.VInputTag(cms.untracked.InputTag("a"), cms.untracked.InputTag("b"), cms.untracked.InputTag("c"), cms.InputTag("d")),
228  )
229  p.d = cms.EDProducer("ab", src=cms.InputTag("a"))
230  p.e = cms.EDProducer("ab", src=cms.InputTag("a"))
231  p.f = cms.EDProducer("ab", src=cms.InputTag("a"))
232  p.g = cms.EDProducer("ab", src=cms.InputTag("a"))
233  p.h = cms.EDProducer("ab", src=cms.InputTag("a"))
234  p.i = cms.EDProducer("ab", src=cms.InputTag("a"))
235  p.sp = SwitchProducerTest(
236  test1 = cms.EDProducer("a", src = cms.InputTag("a"),
237  nested = cms.PSet(src = cms.InputTag("a"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("a"))
238  ),
239  test2 = cms.EDProducer("b", src = cms.InputTag("c"),
240  nested = cms.PSet(src = cms.InputTag("a"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("a"))
241  ),
242  )
243  p.s1 = cms.Sequence(p.a*p.b*p.c*p.sp)
244  p.path1 = cms.Path(p.s1)
245  p.s2 = cms.Sequence(p.d)
246  p.path2 = cms.Path(p.e)
247  p.s3 = cms.Sequence(p.f)
248  p.endpath1 = cms.EndPath(p.s3)
249  p.endpath2 = cms.EndPath(p.g)
250  p.t1 = cms.Task(p.h)
251  p.t2 = cms.Task(p.i)
252  p.schedule = cms.Schedule()
253  p.schedule.associate(p.t1, p.t2)
254  massReplaceInputTag(p, "a", "b", False, False, False)
255  self.assertEqual(cms.InputTag("b"), p.b.src)
256  self.assertEqual(cms.InputTag("b"), p.c.nested.src)
257  self.assertEqual(cms.InputTag("b"), p.c.nested.usrc)
258  self.assertFalse(p.c.nested.usrc.isTracked())
259  self.assertEqual(cms.InputTag("b"), p.c.nestedv[0].src)
260  self.assertEqual(cms.InputTag("b"), p.c.unestedv[0].src)
261  self.assertEqual(cms.InputTag("b"), p.c.vec[0])
262  self.assertEqual(cms.InputTag("c"), p.c.vec[2])
263  self.assertEqual(cms.InputTag("b"), p.c.uvec[0])
264  self.assertEqual(cms.InputTag("c"), p.c.uvec[2])
265  self.assertFalse(p.c.uvec[0].isTracked())
266  self.assertFalse(p.c.uvec[1].isTracked())
267  self.assertFalse(p.c.uvec[2].isTracked())
268  self.assertEqual(cms.InputTag("a"), p.d.src)
269  self.assertEqual(cms.InputTag("b"), p.e.src)
270  self.assertEqual(cms.InputTag("b"), p.f.src)
271  self.assertEqual(cms.InputTag("b"), p.g.src)
272  self.assertEqual(cms.InputTag("b"), p.h.src)
273  self.assertEqual(cms.InputTag("b"), p.i.src)
274  self.assertEqual(cms.InputTag("b"), p.sp.test1.src)
275  self.assertEqual(cms.InputTag("b"), p.sp.test1.nested.src)
276  self.assertEqual(cms.InputTag("c"), p.sp.test1.nested.src2)
277  self.assertEqual(cms.untracked.InputTag("b"), p.sp.test1.nested.usrc)
278  self.assertEqual(cms.InputTag("c"), p.sp.test2.src)
279  self.assertEqual(cms.InputTag("b"), p.sp.test2.nested.src)
280  self.assertEqual(cms.InputTag("c"), p.sp.test2.nested.src2)
281  self.assertEqual(cms.untracked.InputTag("b"), p.sp.test2.nested.usrc)
def massReplaceInputTag
Definition: MassReplace.py:83
def MassReplace.TestModuleCommand.testMassReplaceParam (   self)

Definition at line 310 of file MassReplace.py.

References ConfigBuilder.dumpPython(), and MassReplace.massReplaceParameter().

311  def testMassReplaceParam(self):
312  process1 = cms.Process("test")
313  massReplaceParameter(process1, "src", cms.InputTag("a"), "b", False)
314  self.assertEqual(process1.dumpPython(), cms.Process("test").dumpPython())
315  p = cms.Process("test")
316  p.a = cms.EDProducer("a", src=cms.InputTag("gen"))
317  p.b = cms.EDProducer("ab", src=cms.InputTag("a"))
318  p.c = cms.EDProducer("ac", src=cms.InputTag("b"),
319  nested = cms.PSet(src = cms.InputTag("a"), src2 = cms.InputTag("c")),
320  nestedv = cms.VPSet(cms.PSet(src = cms.InputTag("a")), cms.PSet(src = cms.InputTag("d"))),
321  vec = cms.VInputTag(cms.InputTag("a"), cms.InputTag("b"), cms.InputTag("c"), cms.InputTag("d"))
322  )
323  p.d = cms.EDProducer("ab", src=cms.InputTag("a"))
324  p.e = cms.EDProducer("ab", src=cms.InputTag("a"))
325  p.f = cms.EDProducer("ab", src=cms.InputTag("a"))
326  p.g = cms.EDProducer("ab", src=cms.InputTag("a"))
327  p.h = cms.EDProducer("ab", src=cms.InputTag("a"))
328  p.i = cms.EDProducer("ab", src=cms.InputTag("a"))
329  p.j = cms.EDProducer("ab", src=cms.untracked.InputTag("a"))
330  p.sp = SwitchProducerTest(
331  test1 = cms.EDProducer("a", src = cms.InputTag("a"),
332  nested = cms.PSet(src = cms.InputTag("a"))
333  ),
334  test2 = cms.EDProducer("b", src = cms.InputTag("a")),
335  )
336  p.s1 = cms.Sequence(p.a*p.b*p.c*p.sp)
337  p.path1 = cms.Path(p.s1)
338  p.s2 = cms.Sequence(p.d)
339  p.path2 = cms.Path(p.e)
340  p.s3 = cms.Sequence(p.f)
341  p.endpath1 = cms.EndPath(p.s3)
342  p.endpath2 = cms.EndPath(p.g)
343  p.t1 = cms.Task(p.h)
344  p.t2 = cms.Task(p.i, p.j)
345  p.schedule = cms.Schedule()
346  p.schedule.associate(p.t1, p.t2)
347  massReplaceParameter(p, "src",cms.InputTag("a"), "b", False)
348  self.assertEqual(cms.InputTag("gen"), p.a.src)
349  self.assertEqual(cms.InputTag("b"), p.b.src)
350  self.assertEqual(cms.InputTag("a"), p.c.vec[0])
351  self.assertEqual(cms.InputTag("c"), p.c.vec[2])
352  self.assertEqual(cms.InputTag("a"), p.d.src)
353  self.assertEqual(cms.InputTag("b"), p.e.src)
354  self.assertEqual(cms.InputTag("b"), p.f.src)
355  self.assertEqual(cms.InputTag("b"), p.g.src)
356  self.assertEqual(cms.InputTag("b"), p.h.src)
357  self.assertEqual(cms.InputTag("b"), p.i.src)
358  self.assertEqual(cms.untracked.InputTag("b"), p.j.src)
359  self.assertEqual(cms.InputTag("b"),p.sp.test1.src)
360  self.assertEqual(cms.InputTag("a"),p.sp.test1.nested.src)
361  self.assertEqual(cms.InputTag("b"),p.sp.test2.src)
unittest.main()
def massReplaceParameter
Definition: MassReplace.py:132
def MassReplace.TestModuleCommand.testMassSearchReplaceAnyInputTag (   self)

Definition at line 156 of file MassReplace.py.

References MassReplace.massSearchReplaceAnyInputTag().

158  p = cms.Process("test")
159  p.a = cms.EDProducer("a", src=cms.InputTag("gen"))
160  p.b = cms.EDProducer("ab", src=cms.InputTag("a"))
161  p.c = cms.EDProducer("ac", src=cms.InputTag("b"), usrc=cms.untracked.InputTag("b"),
162  nested = cms.PSet(src = cms.InputTag("b"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("b")),
163  nestedv = cms.VPSet(cms.PSet(src = cms.InputTag("b")), cms.PSet(src = cms.InputTag("d"))),
164  unestedv = cms.untracked.VPSet(cms.untracked.PSet(src = cms.InputTag("b")), cms.untracked.PSet(src = cms.InputTag("d"))),
165  vec = cms.VInputTag(cms.InputTag("a"), cms.InputTag("b"), cms.InputTag("c"), cms.InputTag("d")),
166  uvec = cms.untracked.VInputTag(cms.untracked.InputTag("a"), cms.untracked.InputTag("b"), cms.untracked.InputTag("c"), cms.untracked.InputTag("d")),
167  )
168  p.sp = SwitchProducerTest(
169  test1 = cms.EDProducer("a", src = cms.InputTag("b"),
170  nested = cms.PSet(src = cms.InputTag("b"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("b"))
171  ),
172  test2 = cms.EDProducer("b", src = cms.InputTag("c"),
173  nested = cms.PSet(src = cms.InputTag("b"), src2 = cms.InputTag("c"), usrc = cms.untracked.InputTag("b"))
174  ),
175  )
176  p.op = cms.EDProducer("op", src = cms.optional.InputTag, unset = cms.optional.InputTag, vsrc = cms.optional.VInputTag, vunset = cms.optional.VInputTag)
177  p.op.src="b"
178  p.op.vsrc=cms.VInputTag("b")
179  p.s = cms.Sequence(p.a*p.b*p.c*p.sp*p.op)
180  massSearchReplaceAnyInputTag(p.s, cms.InputTag("b"), cms.InputTag("new"))
181  self.assertNotEqual(cms.InputTag("new"), p.b.src)
182  self.assertEqual(cms.InputTag("new"), p.c.src)
183  self.assertEqual(cms.InputTag("new"), p.c.usrc)
184  self.assertEqual(cms.InputTag("new"), p.c.nested.src)
185  self.assertEqual(cms.InputTag("new"), p.c.nested.usrc)
186  self.assertFalse(p.c.nested.usrc.isTracked())
187  self.assertNotEqual(cms.InputTag("new"), p.c.nested.src2)
188  self.assertEqual(cms.InputTag("new"), p.c.nestedv[0].src)
189  self.assertNotEqual(cms.InputTag("new"), p.c.nestedv[1].src)
190  self.assertEqual(cms.InputTag("new"), p.c.unestedv[0].src)
191  self.assertNotEqual(cms.InputTag("new"), p.c.unestedv[1].src)
192  self.assertNotEqual(cms.InputTag("new"), p.c.vec[0])
193  self.assertEqual(cms.InputTag("new"), p.c.vec[1])
194  self.assertNotEqual(cms.InputTag("new"), p.c.vec[2])
195  self.assertNotEqual(cms.InputTag("new"), p.c.vec[3])
196  self.assertNotEqual(cms.InputTag("new"), p.c.uvec[0])
197  self.assertEqual(cms.InputTag("new"), p.c.uvec[1])
198  self.assertNotEqual(cms.InputTag("new"), p.c.uvec[2])
199  self.assertNotEqual(cms.InputTag("new"), p.c.uvec[3])
200  self.assertFalse(p.c.uvec[0].isTracked())
201  self.assertFalse(p.c.uvec[1].isTracked())
202  self.assertFalse(p.c.uvec[2].isTracked())
203  self.assertFalse(p.c.uvec[3].isTracked())
204  self.assertEqual(cms.InputTag("new"), p.sp.test1.src)
205  self.assertEqual(cms.InputTag("new"), p.sp.test1.nested.src)
206  self.assertEqual(cms.InputTag("c"), p.sp.test1.nested.src2)
207  self.assertEqual(cms.untracked.InputTag("new"), p.sp.test1.nested.usrc)
208  self.assertEqual(cms.InputTag("c"), p.sp.test2.src)
209  self.assertEqual(cms.InputTag("new"), p.sp.test2.nested.src)
210  self.assertEqual(cms.InputTag("c"), p.sp.test2.nested.src2)
211  self.assertEqual(cms.untracked.InputTag("new"), p.sp.test2.nested.usrc)
212  self.assertEqual(cms.InputTag("new"), p.op.src)
213  self.assertEqual(cms.InputTag("new"), p.op.vsrc[0])
def massSearchReplaceAnyInputTag
Definition: MassReplace.py:79
def MassReplace.TestModuleCommand.testMassSearchReplaceParam (   self)

Definition at line 282 of file MassReplace.py.

References MassReplace.massSearchReplaceParam().

283  def testMassSearchReplaceParam(self):
284  p = cms.Process("test")
285  p.a = cms.EDProducer("a", src=cms.InputTag("gen"))
286  p.b = cms.EDProducer("ab", src=cms.InputTag("a"))
287  p.c = cms.EDProducer("ac", src=cms.InputTag("b"),
288  nested = cms.PSet(src = cms.InputTag("c"), src2 = cms.InputTag("b"))
289  )
290  p.d = cms.EDProducer("ac", src=cms.untracked.InputTag("b"),
291  nested = cms.PSet(src = cms.InputTag("c"), src2 = cms.InputTag("b"))
292  )
293  p.sp = SwitchProducerTest(
294  test1 = cms.EDProducer("a", src = cms.InputTag("b"),
295  nested = cms.PSet(src = cms.InputTag("b"))
296  ),
297  test2 = cms.EDProducer("b", src = cms.InputTag("b")),
298  )
299  p.s = cms.Sequence(p.a*p.b*p.c*p.d*p.sp)
300  massSearchReplaceParam(p.s,"src",cms.InputTag("b"),"a")
301  self.assertEqual(cms.InputTag("a"),p.c.src)
302  self.assertEqual(cms.InputTag("c"),p.c.nested.src)
303  self.assertEqual(cms.InputTag("b"),p.c.nested.src2)
304  self.assertEqual(cms.untracked.InputTag("a"),p.d.src)
305  self.assertEqual(cms.InputTag("c"),p.d.nested.src)
306  self.assertEqual(cms.InputTag("b"),p.d.nested.src2)
307  self.assertEqual(cms.InputTag("a"),p.sp.test1.src)
308  self.assertEqual(cms.InputTag("b"),p.sp.test1.nested.src)
309  self.assertEqual(cms.InputTag("a"),p.sp.test2.src)
def massSearchReplaceParam
Definition: MassReplace.py:129