CMS 3D CMS Logo

List of all members | Public Member Functions
MassReplace.TestModuleCommand Class Reference
Inheritance diagram for MassReplace.TestModuleCommand:

Public Member Functions

def testMassReplaceInputTag (self)
 
def testMassReplaceParam (self)
 
def testMassSearchReplaceAnyInputTag (self)
 
def testMassSearchReplaceParam (self)
 

Detailed Description

Definition at line 154 of file MassReplace.py.

Member Function Documentation

◆ testMassReplaceInputTag()

def MassReplace.TestModuleCommand.testMassReplaceInputTag (   self)

Definition at line 219 of file MassReplace.py.

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

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

◆ testMassReplaceParam()

def MassReplace.TestModuleCommand.testMassReplaceParam (   self)

Definition at line 315 of file MassReplace.py.

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

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

◆ testMassSearchReplaceAnyInputTag()

def MassReplace.TestModuleCommand.testMassSearchReplaceAnyInputTag (   self)

Definition at line 156 of file MassReplace.py.

References MassReplace.massSearchReplaceAnyInputTag().

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

◆ testMassSearchReplaceParam()

def MassReplace.TestModuleCommand.testMassSearchReplaceParam (   self)

Definition at line 287 of file MassReplace.py.

References MassReplace.massSearchReplaceParam().

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