def test_prepare_run_of_already_failed_run_mock(self, mock_resolve, mock_prepare_run, mock_start_run): spec_run = MagicMock(cache=V1Cache(disable=True)) mock_resolve.return_value = (None, spec_run) experiment = RunFactory(project=self.project, user=self.user, raw_content="test", is_managed=True) # We are patching the automatic call and executing prepare manually runs_prepare(run_id=experiment.id) experiment.refresh_from_db() assert experiment.status == V1Statuses.COMPILED assert mock_prepare_run.call_count == 1 # Automatic call from executor assert mock_start_run.call_count == 1
def test_prepare_run_of_already_skipped_run(self, mock_resolve): spec_run = MagicMock(cache=V1Cache(disable=False)) mock_resolve.return_value = (None, spec_run) experiment = RunFactory(project=self.project, user=self.user) new_run_status( run=experiment, condition=V1StatusCondition.get_condition(type=V1Statuses.SKIPPED, status=True), ) new_experiment = RunFactory(project=self.project, user=self.user) runs_prepare(run_id=new_experiment.id) new_experiment.refresh_from_db() assert new_experiment.status == V1Statuses.COMPILED