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

Add tests for run by jobcard file

parent 787c2fbe
No related branches found
No related tags found
1 merge request!1Merge python environment
Pipeline #9398 passed
......@@ -59,7 +59,7 @@ def run_jobcard(jobcard, outdir):
with open(jobcard_fpath, 'w') as f:
f.write(str(jobcard))
elif isfile(jobcard):
os.system("cp %s %s" % (jobcard, jobcard_fpath.name))
os.system("cp %s %s" % (jobcard, jobcard_fpath))
else:
log.error("No valid jobcard reference given: %s" % jobcard)
log.info("Create temporary file for associated runscript")
......
......@@ -16,10 +16,27 @@ from km3buu.jobcard import *
from km3buu.ctrl import run_jobcard
from tempfile import TemporaryDirectory
from os import listdir
from os.path import abspath, join, dirname
from thepipe.logger import get_logger
JOBCARD_FOLDER = abspath(join(dirname(__file__), "../../jobcards"))
class TestCTRL(unittest.TestCase):
class TestCTRLbyJobcardFile(unittest.TestCase):
def setUp(self):
self.filename = join(JOBCARD_FOLDER, "examples/example.job")
self.output_dir = TemporaryDirectory()
self.retval = run_jobcard(self.filename, self.output_dir.name)
def test_output(self):
assert self.retval == 0
def test_output_files_existing(self):
files = listdir(self.output_dir.name)
assert "FinalEvents.dat" in files
class TestCTRLbyJobcardObject(unittest.TestCase):
def setUp(self):
log = get_logger("ctrl.py")
log.setLevel("INFO")
......
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