class SplitJoinWorkflow(models.SplitJoinWorkflowState): start = tasks.StartView(fields=[]) def split(self): return [self.batman, self.robin] def batman(self): self.parallel_task_value += 1 self.save(update_fields=["parallel_task_value"]) def robin(self): self.parallel_task_value += 1 self.save(update_fields=["parallel_task_value"]) join = tasks.Join("batman", "robin") edges = ( (start, split), (split, batman), (split, robin), (batman, join), (robin, join), ) class Meta: proxy = True
class SplitJoinProcess(Process): parallel_task_value = models.PositiveIntegerField(default=0) start = views.StartView(fields=[]) def split(self): return [self.batman, self.robin] def batman(self): self.parallel_task_value += 1 self.save(update_fields=['parallel_task_value']) def robin(self): self.parallel_task_value += 1 self.save(update_fields=['parallel_task_value']) join = tasks.Join('batman', 'robin') edges = ( (start, split), (split, batman), (split, robin), (batman, join), (robin, join), )
def test_create_task(self, db): proc = models.SimpleProcess.start_method() node = tasks.Join() node.name = 'test' node.type = 'machine' obj = node.create_task(proc) obj2 = node.create_task(proc) assert obj == obj2 obj.finish() obj3 = node.create_task(proc) assert obj != obj3
def test_create_task(self, db): wf = workflows.SimpleWorkflow.start_method() node = tasks.Join() node.name = "test" node.type = "machine" obj = node.create_task(wf, None) obj2 = node.create_task(wf, None) assert obj == obj2 obj.finish() obj3 = node.create_task(wf, None) assert obj != obj3
def test_call(self, db): proc = models.SimpleProcess.start_method() task = proc.task_set.latest() assert not tasks.Join('does_not_have_the_parent')(None, task) assert tasks.Join('start_method')(None, task)
def test_init(self): node = tasks.Join('1', '2', '3') assert node.parents == {'1', '2', '3'}
def test_call(self, db): wf = workflows.SimpleWorkflow.start_method() assert isinstance(wf, workflows.SimpleWorkflow) task = wf.task_set.latest() assert not tasks.Join("does_not_have_the_parent")(None, task) assert tasks.Join("start_method")(None, task)
def test_init(self): node = tasks.Join("1", "2", "3") assert node.parents == {"1", "2", "3"}