def test_run_no_step(self): """ should fail to run a None step """ support.create_project(self, 'jefferson') project = cd.project.get_internal_project() result = source.run_step(Response(), project, 'FAKE.STEP') self.assertFalse(result)
def test_run_no_step(self): """ should fail to run a None step """ support.create_project(self, 'jefferson') project = cd.project.get_internal_project() result = source.run_step(Response(), project, 'FAKE.STEP') self.assertFalse(result)
def test_run_skip_status(self, *args): """ should succeed without running a with a skip status """ support.create_project(self, 'adams') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] result = source.run_step(Response(), project, step) self.assertTrue(result)
def test_run_error_status(self, *args): """ should fail to run a with an error status """ support.create_project(self, 'john') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] result = source.run_step(Response(), project, step) self.assertFalse(result)
def test_run_skip_status(self, *args): """ should succeed without running a with a skip status """ support.create_project(self, 'adams') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] result = source.run_step(Response(), project, step) self.assertTrue(result)
def test_run_error_status(self, *args): """ should fail to run a with an error status """ support.create_project(self, 'john') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] result = source.run_step(Response(), project, step) self.assertFalse(result)
def test_run_step_execution_error(self): """ should fail when running a step that fails to execute """ support.create_project(self, 'quincy') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] package = 'cauldron.runner.source._execute_step' with patch(package, side_effect=RuntimeError('Not Good!')): result = source.run_step(Response(), project, step) self.assertFalse(result)
def test_run_step_execution_error(self): """ should fail when running a step that fails to execute """ support.create_project(self, 'quincy') support.add_step(self) project = cd.project.get_internal_project() step = project.steps[0] package = 'cauldron.runner.source._execute_step' with patch(package, side_effect=RuntimeError('Not Good!')): result = source.run_step(Response(), project, step) self.assertFalse(result)
def section(response: Response, project: typing.Union[Project, None], starting: ProjectStep = None, limit: int = 1, force: bool = False, skips: typing.List[ProjectStep] = None) -> list: """ :param response: :param project: :param starting: :param limit: :param force: :param skips: Steps that should be skipped while running this section :return: """ limit = max(1, limit) if project is None: project = cauldron.project.internal_project starting_index = 0 if starting: starting_index = project.steps.index(starting) count = 0 steps_run = [] for ps in project.steps: if count >= limit: break if ps.index < starting_index: continue if skips and ps in skips: continue if not force and count == 0 and not ps.is_dirty(): continue steps_run.append(ps) if not source.run_step(response, project, ps, force=force): return steps_run count += 1 return steps_run
def complete(response: Response, project: typing.Union[Project, None], starting: ProjectStep = None, force: bool = False, limit: int = -1) -> list: """ Runs the entire project, writes the results files, and returns the URL to the report file :param response: :param project: :param starting: :param force: :param limit: :return: Local URL to the report path """ if project is None: project = cauldron.project.get_internal_project() starting_index = 0 if starting: starting_index = project.steps.index(starting) count = 0 steps_run = [] for ps in project.steps: if 0 < limit <= count: break if ps.index < starting_index: continue if not force and not ps.is_dirty(): if limit < 1: environ.log('[{}]: Nothing to update'.format( ps.definition.name)) continue count += 1 steps_run.append(ps) success = source.run_step(response, project, ps, force=True) if not success or project.stop_condition.halt: return steps_run return steps_run