Skip to content
Snippets Groups Projects
Commit 1573888e authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Updated tests

parent 1f53cedb
No related branches found
No related tags found
1 merge request!1Merge python environment
......@@ -21,6 +21,9 @@ from thepipe.logger import get_logger
JOBCARD_FOLDER = abspath(join(dirname(__file__), "../../jobcards"))
# class TestCTRLmisc(unittest.TestCase):
# def test_invalid_jobcard(self):
class TestCTRLbyJobcardFile(unittest.TestCase):
def setUp(self):
......@@ -50,7 +53,7 @@ class TestCTRLbyJobcardObject(unittest.TestCase):
XSECTIONMODE_LOOKUP["dSigmaMC"])
self.test_jobcard.set_property("neutrino_induced", "includeDIS", True)
self.test_jobcard.set_property("neutrino_induced", "printAbsorptionXS",
"T")
True)
self.test_jobcard.set_property("nl_SigmaMC", "enu", 1)
# INPUT
self.test_jobcard.set_property("input", "numTimeSteps", 0)
......
......@@ -25,14 +25,15 @@ class TestJobcard(unittest.TestCase):
expected_line = "path_to_input = '%s'" % INPUT_PATH
ctnt = str(self.test_jobcard)
group_start = ctnt.find("&input")
group_end = ctnt.find("/\n\n", group_start)
group_end = ctnt.find("/\n", group_start)
assert ctnt[group_start:group_end].find(expected_line) != -1
def test_elements(self):
ctnt = str(self.test_jobcard)
expected_line = "def = 42"
group_start = ctnt.find("&ABC")
group_end = ctnt.find("/\n\n", group_start)
group_start = ctnt.find("&abc")
group_end = ctnt.find("/", group_start)
print(ctnt)
assert ctnt[group_start:group_end].find(expected_line) != -1
def test_remove_elements(self):
......
......@@ -22,7 +22,7 @@ TESTDATA_DIR = abspath(join(dirname(__file__), "../data/test-data/"))
class TestXSection(unittest.TestCase):
def test_xsection_all(self):
filename = join(TESTDATA_DIR, XSECTION_FILENAMES["all"])
xsection = NeutrinoAbsorptionXSection(filename)
xsection = read_nu_abs_xsection(filename)
self.assertAlmostEqual(xsection['var'], 1.0)
self.assertAlmostEqual(xsection['sum'], 0.61548)
self.assertAlmostEqual(xsection['Delta'], 0.61537)
......@@ -43,7 +43,7 @@ class TestFinalEvents(unittest.TestCase):
self.assertAlmostEqual(self.final_events[0]["p_x"], 2.619802e-2)
self.assertAlmostEqual(self.final_events[0]["p_y"], 3.290991e-1)
self.assertAlmostEqual(self.final_events[0]["p_z"], 3.821936e-1)
self.assertAlmostEqual(self.final_events[0]["energy"], 1.0)
self.assertAlmostEqual(self.final_events[0]["nu_energy"], 1.0)
assert self.final_events[3]["id"] == 1
assert self.final_events[3]["charge"] == 1
self.assertAlmostEqual(self.final_events[3]["perweight"], 6.154773e-1)
......@@ -55,7 +55,7 @@ class TestFinalEvents(unittest.TestCase):
assert self.final_events[0:2] is not None
def test_length(self):
assert len(self.final_events) == 5
assert len(self.final_events) == 4
class TestGiBUUOutput(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment