Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:39

0001 from CondCore.ESSources.GlobalTag import *
0002 import unittest
0003 
0004 class TestGlobalTag(unittest.TestCase):
0005     def setUp(self):
0006         self.GT1 = GlobalTag("PRA_61_V1::All", "sqlite_file:/afs/cern.ch/user/a/alcaprod/public/Alca/GlobalTag/PRE_61_V1.db")
0007         self.GT2 = GlobalTag("PRE_61_V2::All", "sqlite_file:/afs/cern.ch/user/a/alcaprod/public/Alca/GlobalTag/PRE_61_V2.db")
0008         self.GT3 = GlobalTag("PRB_61_V3::All", "sqlite_file:/afs/cern.ch/user/a/alcaprod/public/Alca/GlobalTag/PRE_61_V3.db")
0009         self.GT4 = GlobalTag("PRE_61_V4::All", "sqlite_file:/afs/cern.ch/user/a/alcaprod/public/Alca/GlobalTag/PRE_61_V4.db")
0010         self.Alias = GlobalTag("MAINGT")
0011         self.AliasWithConnectionString = GlobalTag("MAINGT", "frontier://FrontierProd/CMS_COND_31X_GLOBALTAG")
0012 
0013     def test_or(self):
0014         """ Test concatenation of different GT components """
0015         self.globalTag = self.GT1 | self.GT2 | self.GT3
0016         self.assertTrue( self.globalTag.gt() == self.GT1.gt()+"|"+self.GT2.gt()+"|"+self.GT3.gt() )
0017         self.assertTrue( self.globalTag.connect() == self.GT1.connect()+"|"+self.GT2.connect()+"|"+self.GT3.connect() )
0018         self.assertTrue( self.globalTag.pfnPrefix() == self.GT1.pfnPrefix()+"|"+self.GT2.pfnPrefix()+"|"+self.GT3.pfnPrefix() )
0019         self.assertTrue( self.globalTag.pfnPostfix() == self.GT1.pfnPostfix()+"|"+self.GT2.pfnPostfix()+"|"+self.GT3.pfnPostfix() )
0020 
0021     def test_orException(self):
0022         """ Test exception when trying to concatenate the same component type """
0023         try:
0024             self.GT1 | self.GT2 | self.GT4
0025         except GlobalTagBuilderException:
0026             self.assertTrue( True )
0027         else:
0028             self.assertTrue( False )
0029 
0030     def test_add(self):
0031         """ Test replacement of an existing component type """
0032         self.globalTag = (self.GT1 | self.GT2 | self.GT3) + self.GT4
0033         self.assertTrue( self.globalTag.gt() == self.GT1.gt()+"|"+self.GT4.gt()+"|"+self.GT3.gt() )
0034         self.assertTrue( self.globalTag.connect() == self.GT1.connect()+"|"+self.GT4.connect()+"|"+self.GT3.connect() )
0035         self.assertTrue( self.globalTag.pfnPrefix() == self.GT1.pfnPrefix()+"|"+self.GT4.pfnPrefix()+"|"+self.GT3.pfnPrefix() )
0036         self.assertTrue( self.globalTag.pfnPostfix() == self.GT1.pfnPostfix()+"|"+self.GT4.pfnPostfix()+"|"+self.GT3.pfnPostfix() )
0037 
0038     def test_addException(self):
0039         """ Test exception when trying to replace a non existent component type """
0040         try:
0041             (self.GT1 | self.GT3) + self.GT4
0042         except GlobalTagBuilderException:
0043             self.assertTrue( True )
0044         else:
0045             self.assertTrue( False )
0046 
0047     def test_alias(self):
0048         """ Test the aliases """
0049         self.globalTag = (self.Alias)
0050         self.globalTag = (self.AliasWithConnectionString)
0051 
0052 if __name__ == '__main__':
0053     unittest.main()