Skip to content

Commit

Permalink
condor: fixed bug in function and added unit test
Browse files Browse the repository at this point in the history
find_rescue_dag was totally broken
  • Loading branch information
duncanmmacleod committed Apr 5, 2017
1 parent 922f210 commit e519485
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion omicron/condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions omicron/tests/test_condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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))

0 comments on commit e519485

Please sign in to comment.