14import 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"
37 b
"<interval>release</interval>"
38 b
"<output>EvtGenSim.root</output>\n"
39 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
40 b
"<description>description_text</description>\n"
49 script = validationscript.Script(tf.name,
"package",
None)
51 self.assertTrue(interval_sel.in_interval(script))
53 with tempfile.NamedTemporaryFile()
as tf:
55 b
"#!/usr/bin/env python3\n"
58 b
"<interval>nightly</interval>"
59 b
"<output>EvtGenSim.root</output>\n"
60 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
61 b
"<description>description_text</description>\n"
70 script = validationscript.Script(tf.name,
"package",
None)
72 self.assertTrue(interval_sel.in_interval(script))
76 Test if the interval selection works
if there
is no
77 interval setting
in the validation header
79 with tempfile.NamedTemporaryFile()
as tf:
81 b
"#!/usr/bin/env python3\n"
84 b
"<output>EvtGenSim.root</output>\n"
85 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
86 b
"<description>description_text</description>\n"
95 script = validationscript.Script(tf.name,
"package",
None)
99 self.assertTrue(interval_sel.in_interval(script))
103 Test if the package selection works
and if the required dependencies are
107 val = validation.Validation()
109 script1 = validation.Script("val1.py",
"tracking",
None)
110 script2 = validation.Script(
"val2.py",
"tracking",
None)
111 script3 = validation.Script(
"valOther.py",
"other_package",
None)
112 script4 = validation.Script(
113 "valOtherNotDepending.py",
"other_package",
None
115 script2.dependencies = [script3]
117 val.add_script(script1)
118 val.add_script(script2)
119 val.add_script(script3)
120 val.add_script(script4)
123 val.apply_package_selection([
"tracking"],
False)
125 self.assertEqual(3, len(val.scripts))
132 if s.unique_name() == script3.unique_name()
142 if s.unique_name() == script4.unique_name()
147 val_no_deps = validation.Validation()
149 val_no_deps.add_script(script1)
150 val_no_deps.add_script(script2)
151 val_no_deps.add_script(script3)
152 val_no_deps.add_script(script4)
155 val_no_deps.apply_package_selection([
"tracking"],
True)
157 self.assertEqual(2, len(val_no_deps.scripts))
163 for s
in val_no_deps.scripts
164 if s.unique_name() == script3.unique_name()
171 Test if the interval selection works
if there
is no
172 interval setting
in the validation header
174 with tempfile.NamedTemporaryFile()
as tf:
176 b
"#!/usr/bin/env python3\n"
179 b
"<input>SomeIn.root</input>\n"
180 b
"<output>EvtGenSim.root</output>\n"
182 b
"<contact>Kilian Lieret kilian.lieret@lmu.de</contact>\n"
183 b
"<description>description_text</description>\n"
192 script = validationscript.Script(tf.name,
"package",
None)
194 self.assertTrue(script.is_cacheable)
195 self.assertTrue(
"EvtGenSim.root" in script.output_files)
196 self.assertTrue(
"SomeIn.root" in script.input_files)
200 Test if the meta options parsers behaves nice
203 ["shifter",
"pvalue-warn=0.9",
"pvalue-error=0.4"]
206 self.assertEqual(0.9, p.pvalue_warn())
207 self.assertEqual(0.4, p.pvalue_error())
208 self.assertTrue(p.has_option(
"shifter"))
209 self.assertFalse(p.has_option(
"not is list"))
213 self.assertEqual(
None, p.pvalue_warn())
214 self.assertEqual(
None, p.pvalue_error())
217if __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)