Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:52

0001 from readProv import *
0002 from diffProv import *
0003 import unittest
0004 
0005 
0006 if __name__=="__main__":
0007     
0008     class testEdmProvDiff(unittest.TestCase):
0009 
0010         def setUp(self):
0011             self._r=filereader()
0012             self._d=difference(2)
0013 
0014         def testStartswith(self):
0015             """ Check the method startswith() of class filereader
0016             """
0017             r='Module: modulename'
0018             a=self._r.startswith(r)
0019             self.assertEqual(a, True)
0020             s='ESSource: modulename'
0021             b=self._r.startswith(s)
0022             self.assertEqual(b, True)
0023             t='ESModule: modulename'
0024             c=self._r.startswith(t)
0025             self.assertEqual(c, False)
0026             u='SModule: modulename'
0027             d=self._r.startswith(u)
0028             self.assertEqual(d, False)
0029 
0030 
0031         def testKeys(self):
0032             """ Check modules names stored by the method readfile() 
0033                 of class filereader 
0034             """
0035             moduleblock1={}
0036             moduleblock2={}
0037             moduleblock1=self._r.readfile('newfile')
0038             moduleblock2=self._r.readfile('newfile2')
0039             keys1=sorted(moduleblock1.keys())
0040             keys2=moduleblock2.keys()
0041             keys2.sort()
0042             self.assertEqual(keys1,['HLT2','Processing'])
0043             self.assertEqual(keys2,['HLT','Processing'])
0044             
0045         def testValueModule(self):
0046             """ Check modules stored by the method readfile()
0047                 of class filereader
0048             """
0049             moduleblock={}
0050             file='newfile'
0051             moduleblock=self._r.readfile(file)
0052             key='HLT2'
0053             try:
0054                 moduleblock[key]
0055             except KeyError:
0056                 print("No process "+key + "run ")   
0057             try:
0058                 label=moduleblock[key][0][0]
0059             except ValueError:
0060                 print("No module "+label +" in the process "+ key + ' in the file '+ file)
0061 
0062             value=moduleblock[key][0][1]
0063             block=('Module: genCandidatesForMET HLT2', ' parameters: {', '  excludeResonances: bool tracked  = false', '  partonicFinalState: bool tracked  = false','}{', '}{', '}', '')
0064  
0065             self.assertEqual(block,value)
0066                         
0067         def testListDifferences(self):
0068             """ Check the differences between the parameters of a same module
0069                 run on two different edm files with different parameter values
0070             """
0071             moduleblock1={}
0072             moduleblock2={}
0073             moduleblock1=self._r.readfile('newfile')
0074             moduleblock2=self._r.readfile('newfile2')
0075             key1='HLT2'
0076             key2='HLT'
0077             module1=moduleblock1[key1][0][1]
0078             module2=moduleblock2[key2][0][1]
0079             file1= 'first file'
0080             file2= 'second file'
0081             result=['excludeResonances: bool tracked  = false  [first file]','                                   true  [second file]', 'partonicFinalState: bool tracked  = false  [first file]','                                    true  [second file]']
0082             self.assertEqual(result, self._d.list_diff(module1,module2,file1,file2))
0083 
0084                     
0085             
0086     unittest.main()