示例#1
0
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
示例#2
0
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),
    )
示例#3
0
 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
示例#4
0
 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
示例#5
0
 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)
示例#6
0
 def test_init(self):
     node = tasks.Join('1', '2', '3')
     assert node.parents == {'1', '2', '3'}
示例#7
0
 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)
示例#8
0
 def test_init(self):
     node = tasks.Join("1", "2", "3")
     assert node.parents == {"1", "2", "3"}