def test_restore_state(self): run_collection = jobrun.JobRunCollection(20) state_data = [ dict( run_num=i, job_name="thename", run_time="sometime", start_time="start_time", end_time="sometime", cleanup_run=None, runs=[], ) for i in range(3, -1, -1) ] action_graph = mock.create_autospec(actiongraph.ActionGraph) output_path = mock.create_autospec(filehandler.OutputPath) context = mock.Mock() node_pool = mock.create_autospec(node.NodePool) restored_runs = run_collection.restore_state( state_data, action_graph, output_path, context, node_pool, ) assert_equal(run_collection.runs[0].run_num, 3) assert_equal(run_collection.runs[3].run_num, 0) assert_length(restored_runs, 4)
def setup_runs(self): self.run_collection = jobrun.JobRunCollection(5) self.job_runs = [ self._mock_run(state=actionrun.ActionRun.STATE_QUEUED, run_num=4), self._mock_run(state=actionrun.ActionRun.STATE_RUNNING, run_num=3) ] + [ self._mock_run(state=actionrun.ActionRun.STATE_SUCCEEDED, run_num=i) for i in xrange(2,0,-1) ] self.run_collection.runs.extend(self.job_runs) self.mock_node = mock.create_autospec(node.Node)
def test_remove_old_runs_no_runs(self): run_collection = jobrun.JobRunCollection(4) run_collection.remove_old_runs()
def test_get_next_run_num_first(self): run_collection = jobrun.JobRunCollection(5) assert_equal(run_collection.next_run_num(), 0)
def test_get_newest_no_runs(self): run_collection = jobrun.JobRunCollection(5) assert_equal(run_collection.get_newest(), None)