Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:07

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