Belle II Software development
test_validationscript.py
1#!/usr/bin/env python3
2
3
10
11import unittest
12import tempfile
13import validationscript
14
15call_iteration = 0
16
17
18class ValidationScriptTest(unittest.TestCase):
19
20 """
21 Various test cases for the Script class
22 """
23
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'"""\n'
32 b"<header>\n"
33 b"<interval>release</interval>"
34 b"<output>EvtGenSim.root</output>\n"
35 b"<contact>Thomas Kuhr thomas.kuhr@lmu.de</contact>\n"
36 b"<description>description_text</description>\n"
37 b"</header>\n"
38 b'"""\n'
39 )
40
41 # flush file content, so it can be read by the Script class used
42 # below
43 tf.flush()
44
45 script = validationscript.Script(tf.name, "package", None)
46 script.load_header()
47
48 self.assertEqual("description_text", script.description)
49 self.assertEqual(
50 "Thomas Kuhr thomas.kuhr@lmu.de", script.contact[0]
51 )
52 self.assertEqual(1, len(script.output_files))
53 self.assertEqual("EvtGenSim.root", script.output_files[0])
54 self.assertEqual("release", script.interval)
55
56
57if __name__ == "__main__":
58 unittest.main()