14 import validationscript
23 Various test cases for the validation module
28 Test if the interval selection works
32 with tempfile.NamedTemporaryFile()
as tf:
34 b
"#!/usr/bin/env python3\n"
35 b
"# -*- coding: utf-8 -*-\n"
38 b
"<interval>release</interval>"
39 b
"<output>EvtGenSim.root</output>\n"
40 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
41 b
"<description>description_text</description>\n"
50 script = validationscript.Script(tf.name,
"package",
None)
52 self.assertTrue(interval_sel.in_interval(script))
54 with tempfile.NamedTemporaryFile()
as tf:
56 b
"#!/usr/bin/env python3\n"
57 b
"# -*- coding: utf-8 -*-\n"
60 b
"<interval>nightly</interval>"
61 b
"<output>EvtGenSim.root</output>\n"
62 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
63 b
"<description>description_text</description>\n"
72 script = validationscript.Script(tf.name,
"package",
None)
74 self.assertTrue(interval_sel.in_interval(script))
78 Test if the interval selection works if there is no
79 interval setting in the validation header
81 with tempfile.NamedTemporaryFile()
as tf:
83 b
"#!/usr/bin/env python3\n"
84 b
"# -*- coding: utf-8 -*-\n"
87 b
"<output>EvtGenSim.root</output>\n"
88 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
89 b
"<description>description_text</description>\n"
98 script = validationscript.Script(tf.name,
"package",
None)
102 self.assertTrue(interval_sel.in_interval(script))
106 Test if the package selection works and if the required dependecies are
110 val = validation.Validation()
112 script1 = validation.Script(
"val1.py",
"tracking",
None)
113 script2 = validation.Script(
"val2.py",
"tracking",
None)
114 script3 = validation.Script(
"valOther.py",
"other_package",
None)
115 script4 = validation.Script(
116 "valOtherNotDepending.py",
"other_package",
None
118 script2.dependencies = [script3]
120 val.add_script(script1)
121 val.add_script(script2)
122 val.add_script(script3)
123 val.add_script(script4)
126 val.apply_package_selection([
"tracking"],
False)
128 self.assertEqual(3, len(val.scripts))
135 if s.unique_name() == script3.unique_name()
145 if s.unique_name() == script4.unique_name()
150 val_no_deps = validation.Validation()
152 val_no_deps.add_script(script1)
153 val_no_deps.add_script(script2)
154 val_no_deps.add_script(script3)
155 val_no_deps.add_script(script4)
158 val_no_deps.apply_package_selection([
"tracking"],
True)
160 self.assertEqual(2, len(val_no_deps.scripts))
166 for s
in val_no_deps.scripts
167 if s.unique_name() == script3.unique_name()
174 Test if the interval selection works if there is no
175 interval setting in the validation header
177 with tempfile.NamedTemporaryFile()
as tf:
179 b
"#!/usr/bin/env python3\n"
180 b
"# -*- coding: utf-8 -*-\n"
183 b
"<input>SomeIn.root</input>\n"
184 b
"<output>EvtGenSim.root</output>\n"
186 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
187 b
"<description>description_text</description>\n"
196 script = validationscript.Script(tf.name,
"package",
None)
198 self.assertTrue(script.is_cacheable)
199 self.assertTrue(
"EvtGenSim.root" in script.output_files)
200 self.assertTrue(
"SomeIn.root" in script.input_files)
204 Test if the meta options parsers behaves nice
207 [
"shifter",
"pvalue-warn=0.9",
"pvalue-error=0.4"]
210 self.assertEqual(0.9, p.pvalue_warn())
211 self.assertEqual(0.4, p.pvalue_error())
212 self.assertTrue(p.has_option(
"shifter"))
213 self.assertFalse(p.has_option(
"not is list"))
217 self.assertEqual(
None, p.pvalue_warn())
218 self.assertEqual(
None, p.pvalue_error())
221 if __name__ ==
"__main__":
def test_interval_selection_default(self)
def test_parse_header(self)
def test_apply_package_selection(self)
def test_interval_selection(self)
def test_meta_option_parser(self)