diff --git a/omicron/condor.py b/omicron/condor.py index df19ce5..c1843c3 100644 --- a/omicron/condor.py +++ b/omicron/condor.py @@ -142,7 +142,7 @@ def find_rescue_dag(dagfile): if no related rescue DAG files are found """ try: - return sorted(glob('%s.rescue[0-9][0-9][0-9]'))[-1] + return sorted(glob('%s.rescue[0-9][0-9][0-9]' % dagfile))[-1] except IndexError as e: e.args = ('No rescue DAG files found',) raise diff --git a/omicron/tests/test_condor.py b/omicron/tests/test_condor.py index cd70053..84f8387 100644 --- a/omicron/tests/test_condor.py +++ b/omicron/tests/test_condor.py @@ -27,6 +27,9 @@ sys.modules['htcondor'] = mock_htcondor sys.modules['classad'] = mock_classad +import os.path +import tempfile + import utils from compat import (unittest, mock) @@ -111,3 +114,11 @@ def test_dag_is_running(self): with mock.patch('htcondor.Schedd', schedd_): self.assertTrue(condor.dag_is_running('test.dag')) self.assertFalse(condor.dag_is_running('test2.dag')) + + def test_find_rescue_dag(self): + with tempfile.NamedTemporaryFile(suffix='.dag.rescue001') as f: + dagf = os.path.splitext(f.name)[0] + self.assertEqual(condor.find_rescue_dag(dagf), f.name) + with self.assertRaises(IndexError) as exc: + self.assertEqual(condor.find_rescue_dag(dagf), f.name) + self.assertIn('No rescue DAG files found', str(exc.exception))