ATLAS Offline Software
DataQualityUtils/python/TestCases.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # None of this works, but keep it around in case someone wants to resurrect it later...
4 # - PO 20180419
5 from __future__ import print_function
6 
7 import unittest
8 import os, shutil
9 
10 TESTING_DIR = '/afs/cern.ch/user/a/atlasdqm/dqmdisk1/testing_references'
11 
12 class DQUTestCase(unittest.TestCase):
13  def setUp(self):
14  self.outfile = ''
15 
16  def test_01_Merging(self):
17  '''Test that histogram merging + postprocessing works'''
18  print()
19  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
20  print('Running merge test ....')
21  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
22  outdir = os.environ.get('TMPDIR', '.')
23  inlist = os.path.join(TESTING_DIR, 'test_merging')
24  self.outfile = os.path.join(outdir, 'data09_calophys.00128005.physics_CosmicMuons.root')
25  rv = os.system('cd %s ; DQHistogramMerge.py %s %s True' % (outdir, inlist, self.outfile))
26  self.assertTrue(rv==0, "DQHistogramMerge.py return code is nonzero")
27 
28  def test02_WebDisplay(self):
29  '''Test that a terminal web display job works'''
30  print()
31  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
32  print('Running web display test ....')
33  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
34  outdir = os.environ.get('TMPDIR', '.')
35  infile = os.path.join(TESTING_DIR, 'data09_calophys.00128005.physics_CosmicMuons.root')
36  rv = os.system('cd %s ; DQWebDisplay.py %s TestDisplay 123' % (outdir, infile))
37  self.assertTrue(rv==0, "DQWebDisplay.py return code is nonzero")
38 
39  def test_03_WebDisplay(self):
40  '''Test that a terminal web display job works in temporary accumulation mode'''
41  print()
42  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
43  print('Running intermediate web display test ....')
44  print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
45  outdir = os.environ.get('TMPDIR', '.')
46  infile = os.path.join(TESTING_DIR, 'data09_calophys.00128005.physics_CosmicMuons.root')
47  from DataQualityConfigurations.TestDisplay import dqconfig
48  cachedir = dqconfig.histogramCache
49  if cachedir == '':
50  self.fail('Unable to test intermediate web displays; no histogramCache directory set')
51  if not os.access(cachedir, os.W_OK):
52  print("No write permissions for cache dir %s; skipping test" % cachedir)
53  return
54  cachefilename = os.path.basename(infile).rsplit('.',1)[-2] + '.CACHE_1'
55  shutil.copy(infile, os.path.join(cachedir, cachefilename))
56 
57  rv = os.system('cd %s ; DQWebDisplay.py %s TestDisplay 123 True' % (outdir, infile))
58  self.assertTrue(rv==0, "DQWebDisplay.py return code is nonzero")
59 
60  def tearDown(self):
61  try:
62  if self.outfile != '':
63  os.unlink(self.outfile)
64  except OSError:
65  pass
66 
67 def suite():
68  suite = unittest.TestLoader().loadTestsFromTestCase(DQUTestCase)
69  return suite
70 
71 if __name__ == '__main__':
72  unittest.main()
python.TestCases.DQUTestCase.tearDown
def tearDown(self)
Definition: DataQualityUtils/python/TestCases.py:60
python.TestCases.DQUTestCase
Definition: DataQualityUtils/python/TestCases.py:12
python.TestCases.DQUTestCase.test_03_WebDisplay
def test_03_WebDisplay(self)
Definition: DataQualityUtils/python/TestCases.py:39
python.TestCases.DQUTestCase.test02_WebDisplay
def test02_WebDisplay(self)
Definition: DataQualityUtils/python/TestCases.py:28
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.TestCases.suite
def suite()
Definition: DataQualityConfigurations/python/TestCases.py:73
python.TestCases.DQUTestCase.outfile
outfile
Definition: DataQualityUtils/python/TestCases.py:14
python.TestCases.DQUTestCase.setUp
def setUp(self)
Definition: DataQualityUtils/python/TestCases.py:13
python.TestCases.DQUTestCase.test_01_Merging
def test_01_Merging(self)
Definition: DataQualityUtils/python/TestCases.py:16