Belle II Software  release-08-01-10
test_validationscript.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import unittest
12 import tempfile
13 import validationscript
14 
15 call_iteration = 0
16 
17 
18 class ValidationScriptTest(unittest.TestCase):
19 
20  """
21  Various test cases for the Script class
22  """
23 
24  def test_parse_header(self):
25  """
26  Test if the xml header in validation scripts are parsed properly
27  """
28  with tempfile.NamedTemporaryFile() as tf:
29  tf.write(
30  b"#!/usr/bin/env python3\n"
31  b"# -*- coding: utf-8 -*-\n"
32  b'"""\n'
33  b"<header>\n"
34  b"<interval>release</interval>"
35  b"<output>EvtGenSim.root</output>\n"
36  b"<contact>Thomas Kuhr thomas.kuhr@lmu.de</contact>\n"
37  b"<description>description_text</description>\n"
38  b"</header>\n"
39  b'"""\n'
40  )
41 
42  # flush file content, so it can be read by the Script class used
43  # below
44  tf.flush()
45 
46  script = validationscript.Script(tf.name, "package", None)
47  script.load_header()
48 
49  self.assertEqual("description_text", script.description)
50  self.assertEqual(
51  "Thomas Kuhr thomas.kuhr@lmu.de", script.contact[0]
52  )
53  self.assertEqual(1, len(script.output_files))
54  self.assertEqual("EvtGenSim.root", script.output_files[0])
55  self.assertEqual("release", script.interval)
56 
57 
58 if __name__ == "__main__":
59  unittest.main()