def test_run_good(self): import hod.rmscheduler.rm_pbs as rm_pbs job = rm_pbs.PbsJob('good-jobid.master23.hod.os', 'good-state', 'good-host') with patch('hod.rmscheduler.rm_pbs.Pbs', return_value=Mock(state=lambda: [job])): with patch('hod.cluster.rm_cluster_info'): with patch('hod.cluster.rm_cluster_localworkdir'): with patch('os.getenv', return_value='master23.hod.os'): app = CleanSubCommand() with capture(app.run, []) as (out, err): self.assertEqual(out, '')
def test_run_one_job(self): expected = 'Cluster label\tJob ID \tState \tHosts \n' expected += 'mylabel \tgood-jobid.good-master\tgood-state\tgood-host\n' import hod.rmscheduler.rm_pbs as rm_pbs job = rm_pbs.PbsJob('good-jobid.good-master', 'good-state', 'good-host') with patch('hod.rmscheduler.rm_pbs.Pbs', return_value=Mock(state=lambda: [job])): with patch('hod.rmscheduler.rm_pbs.master_hostname', return_value='good-master'): with patch('hod.cluster.cluster_jobid', return_value='good-jobid.good-master'): with patch('hod.cluster.known_cluster_labels', return_value=['mylabel']): app = hsl.ListSubCommand() app.run([]) with capture(app.run, []) as (out, err): self.assertEqual(out, expected)
def state(self, jobid=None, fltr=None): return [ rm_pbs.PbsJob('1234', 'R', '127.0.0.1'), rm_pbs.PbsJob('q123', 'Q', '127.0.0.1'), rm_pbs.PbsJob('h123', 'H', '127.0.0.1'), ]
def test_format_state_multiple(self): job1 = hrr.PbsJob('123', 'R', 'host1') job2 = hrr.PbsJob('abc', 'Q', '') expected = 'Found 2 jobs\n Id 123 State R Node host1\n Id abc State Q Node ' self.assertTrue(expected, hrr.format_state([job1, job2]))
def test_format_state_single(self): job = hrr.PbsJob('123', 'R', 'host1') expected = 'Found 1 job Id 123 State R Node host1' self.assertTrue(expected, hrr.format_state([job]))