ATLAS Offline Software
Loading...
Searching...
No Matches
DataQualityConfigurations/python/TestCases.py
Go to the documentation of this file.
1# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2
3
4import unittest
5import os, sys
6
7class DQCTestCase(unittest.TestCase):
8 def setUp(self):
9 self.modlist = []
10
11 def do_imports(self, verbose=False):
12 import DataQualityConfigurations
13 for i in DataQualityConfigurations.__all__:
14 if verbose: print ('Importing', i)
15 modname = 'DataQualityConfigurations.%s' % i
16 __import__(modname)
17 self.modlist.append(sys.modules[modname])
18
20 '''Test that we can read the python config files ok'''
21 self.do_imports(verbose=True)
22 self.assert_(len(self.modlist) > 0, 'Should have more than one config module')
23
25 self.do_imports()
26 for mod in self.modlist:
27 self.assert_(mod.dqconfig)
28
30 self.do_imports()
31 for mod in self.modlist:
32 for f in ('hcfg', 'hcfg_min10', 'hcfg_min30'):
33 mf = getattr(mod.dqconfig, f)
34 if mf != '':
35 self.failUnless(os.access(mf, os.R_OK),
36 'File %s not readable in configuration %s' % (mf, mod.__name__) )
37 self.failUnless('/afs/cern.ch/user/a/atlasdqm/dqmdisk/tier0/han_config/' in mf,
38 'Invalid location %s for a production hcfg file in %s' % (mf, mod.__name__) )
39
41 self.do_imports()
42 from DataQualityConfigurations import getmodule
43 # OK for modules that should explicitly be around?
44 for mod in self.modlist:
45 self.assertTrue(getmodule(mod.__name__.replace('DataQualityConfigurations.', '')))
46
47 # OK for some modules that do not exist?
48 for mname in ('data15_hi',
49 'data15_hip',
50 'data15_900GeV',
51 'data15_2p76TeV',
52 'data15_5TeV',
53 'data15_7TeV',
54 'data15_8TeV',
55 'data15_13TeV',
56 'data15_1beam',
57 'data15_cos',
58 'data15_calib',
59 'data15_calocomm',
60 'data15_larcomm',
61 'data15_tilecomm',
62 'data15_muoncomm',
63 'data15_idcomm',
64 'data15_comm',
65 'data15',
66 ):
67 self.assertTrue(getmodule(mname))
68
69 # Fails otherwise?
70 self.assertRaises(ValueError, getmodule, 'NonExistentPtag')
71
72def suite():
73 suite = unittest.TestLoader().loadTestsFromTestCase(DQCTestCase)
74 return suite
75
76if __name__ == '__main__':
77 unittest.main()