def testFinishedJobsOneUnfinishedJob(self, subprocessMock): """ The finishedJobs method should return an empty set if the specification emitted one job that is not finished. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'startAfter': None, 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [123], }, }, ], } subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n' '123|name|RUNNING|04:32:00|cpu-4\n') sps = SlurmPipelineStatus(status) self.assertEqual(set(), sps.finishedJobs())
def testFinishedJobsMultipleSteps(self, subprocessMock): """ The finishedJobs method should return the expected job ids if the specification has multiple steps. """ status = { 'force': False, 'lastStep': None, 'scheduledAt': 1481379658.5455897, 'scriptArgs': [], 'skip': [], 'startAfter': None, 'steps': [ { 'name': 'start', 'scheduledAt': 1481379659.1530972, 'script': 'start.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'xxx': [12, 34], }, }, { 'name': 'end', 'scheduledAt': 1481379659.1530972, 'script': 'end.sh', 'stdout': '', 'taskDependencies': {}, 'tasks': { 'yyy': [56, 78, 90], }, }, ], } subprocessMock.return_value = ('JobID|JobName|State|Elapsed|Nodelist\n' '12|name|RUNNING|04:32:00|cpu-3\n' '34|name|COMPLETED|04:32:00|cpu-3\n' '56|name|RUNNING|04:32:00|cpu-4\n' '78|name|COMPLETED|04:32:00|cpu-4\n' '90|name|RUNNING|04:32:00|cpu-5\n') sps = SlurmPipelineStatus(status) self.assertEqual({34, 78}, sps.finishedJobs())