diff --git a/km3buu/ctrl.py b/km3buu/ctrl.py index 237610e01a45f4abbf7b99fe993e920cb0dd067c..f7a510bbb0d529b669473f1d5d8e97f2fcae270e 100644 --- a/km3buu/ctrl.py +++ b/km3buu/ctrl.py @@ -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") diff --git a/km3buu/tests/test_ctrl.py b/km3buu/tests/test_ctrl.py index f11f4c4ab2a16af88212e25a394b7f24cece65cc..8595f64e36ab0fb1a823e91f0649050aa6271946 100644 --- a/km3buu/tests/test_ctrl.py +++ b/km3buu/tests/test_ctrl.py @@ -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")