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