def setUp(self): interface = ComponentInterface.objects.get( slug="generic-medical-image") archive = ArchiveFactory() ais = ArchiveItemFactory.create_batch(2) archive.items.set(ais) input_civs = ComponentInterfaceValueFactory.create_batch( 2, interface=interface) output_civs = ComponentInterfaceValueFactory.create_batch( 2, interface=interface) for ai, civ in zip(ais, input_civs): ai.values.set([civ]) alg = AlgorithmImageFactory() submission = SubmissionFactory(algorithm_image=alg) submission.phase.archive = archive submission.phase.save() submission.phase.algorithm_inputs.set([interface]) jobs = [] for inpt, output in zip(input_civs, output_civs): j = AlgorithmJobFactory(status=Job.SUCCESS, algorithm_image=alg) j.inputs.set([inpt]) j.outputs.set([output]) jobs.append(j) self.evaluation = EvaluationFactory( submission=submission, status=Evaluation.EXECUTING_PREREQUISITES) self.jobs = jobs self.output_civs = output_civs
def test_set_evaluation_inputs(self): submission = SubmissionFactory() evaluation = EvaluationFactory(submission=submission) jobs = AlgorithmJobFactory.create_batch(2, status=Job.SUCCESS) civs = ComponentInterfaceValueFactory.create_batch(2) for alg, civ in zip(jobs, civs): alg.outputs.set([civ]) set_evaluation_inputs(evaluation_pk=evaluation.pk, job_pks=[j.pk for j in jobs]) evaluation.refresh_from_db() assert evaluation.status == evaluation.PENDING assert evaluation.error_message == "" assert evaluation.inputs.count() == 1
def test_set_evaluation_inputs(self): submission = SubmissionFactory() evaluation = EvaluationFactory(submission=submission) algorithms = AlgorithmEvaluationFactory.create_batch( 2, status=AlgorithmEvaluation.SUCCESS, submission=submission) civs = ComponentInterfaceValueFactory.create_batch(2) for alg, civ in zip(algorithms, civs): alg.outputs.set([civ]) set_evaluation_inputs(evaluation_pk=evaluation.pk) evaluation.refresh_from_db() assert evaluation.status == evaluation.PENDING assert evaluation.output == "" assert list(evaluation.inputs.all()) == civs