def test_get_pending_childs(self): """ |-- child1 parent --| |-- child2 """ workflow = Workflow.objects.create(name='main') process = Process.objects.create(workflow=workflow) parent = Node.objects.create(name='parent', workflow=workflow, celery_task=dummy, role=self.bosses) parent_task = Task.objects.create(node=parent, process=process, user=self.boss) child1 = Node.objects.create(name='one', workflow=workflow, celery_task=dummy, role=self.bosses) child2 = Node.objects.create(name='two', workflow=workflow, celery_task=dummy, role=self.bosses) Transition.objects.create(workflow=workflow, parent=parent, child=child1) Transition.objects.create(workflow=workflow, parent=parent, child=child2) # If the parent is not successful, no child is returned self.assertEqual(len(shortcuts.get_pending_childs(parent_task)), 0) shortcuts.update_task(parent_task.pk, state='SUCCESS') # If a parent is successful and had a XOR split, one child is returned parent.split = 'XOR' parent.save() self.assertEqual(len(shortcuts.get_pending_childs(parent_task)), 1) # If a parent is successful and had an AND split, all childs are returned parent.split = 'AND' parent.save() self.assertEqual(len(shortcuts.get_pending_childs(parent_task)), 2)
def get_pending_childs(self): return get_pending_childs(self)