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