Exemplo n.º 1
0
    def test_is_launchable(self):
        """
        node1 -----
                  |-- join_node
        node2------
        """
        workflow = Workflow.objects.create(name='main')
        process = Process.objects.create(workflow=workflow)

        join_node = Node.objects.create(name='join',
                                        workflow=workflow,
                                        join='XOR',
                                        celery_task=dummy,
                                        role=self.bosses)
        node1 = Node.objects.create(name='one',
                                    workflow=workflow,
                                    celery_task=dummy,
                                    role=self.bosses)
        node2 = Node.objects.create(name='two',
                                    workflow=workflow,
                                    celery_task=dummy,
                                    role=self.bosses)

        # With no parent transitions, it must be always launchable
        self.assertTrue(shortcuts.is_launchable(join_node, process))

        task1 = Task.objects.create(node=node1,
                                    process=process,
                                    user=self.boss)
        task2 = Task.objects.create(node=node2,
                                    process=process,
                                    user=self.boss)

        Transition.objects.create(workflow=workflow,
                                  parent=node1,
                                  child=join_node)
        Transition.objects.create(workflow=workflow,
                                  parent=node2,
                                  child=join_node)

        # With parent transitions but without fulfilled tasks, it's not launchable
        self.assertFalse(shortcuts.is_launchable(join_node, process))

        # With a XOR join and with one fulfilled task, it's launchable
        shortcuts.update_task(task1.pk, state='SUCCESS')
        self.assertTrue(shortcuts.is_launchable(join_node, process))

        # With an AND join and with one fulfilled task, it's not launchable
        join_node.join = 'AND'
        join_node.save()
        self.assertFalse(shortcuts.is_launchable(join_node, process))

        # With an AND join and with all tasks fulfilled, it's launchable
        shortcuts.update_task(task2.pk, state='SUCCESS')
        self.assertTrue(shortcuts.is_launchable(join_node, process))
Exemplo n.º 2
0
    def test_is_launchable(self):
        """
        node1 -----
                  |-- join_node
        node2------
        """
        workflow = Workflow.objects.create(name='main')
        process = Process.objects.create(workflow=workflow)

        join_node = Node.objects.create(name='join', workflow=workflow,
                join='XOR', celery_task=dummy, role=self.bosses)
        node1 = Node.objects.create(name='one', workflow=workflow, 
                celery_task=dummy, role=self.bosses)
        node2 = Node.objects.create(name='two', workflow=workflow, 
                celery_task=dummy, role=self.bosses)

        # With no parent transitions, it must be always launchable
        self.assertTrue(shortcuts.is_launchable(join_node, process))

        task1 = Task.objects.create(node=node1, process=process,
                user=self.boss)
        task2 = Task.objects.create(node=node2, process=process,
                user=self.boss)

        Transition.objects.create(workflow=workflow, parent=node1, 
                child=join_node)
        Transition.objects.create(workflow=workflow, parent=node2,
                child=join_node)

        # With parent transitions but without fulfilled tasks, it's not launchable
        self.assertFalse(shortcuts.is_launchable(join_node, process))

        # With a XOR join and with one fulfilled task, it's launchable
        shortcuts.update_task(task1.pk, state='SUCCESS')
        self.assertTrue(shortcuts.is_launchable(join_node, process))

        # With an AND join and with one fulfilled task, it's not launchable
        join_node.join = 'AND'; join_node.save()
        self.assertFalse(shortcuts.is_launchable(join_node, process))

        # With an AND join and with all tasks fulfilled, it's launchable
        shortcuts.update_task(task2.pk, state='SUCCESS')
        self.assertTrue(shortcuts.is_launchable(join_node, process))
Exemplo n.º 3
0
 def is_launchable(self, process):
     return is_launchable(self, process)
Exemplo n.º 4
0
 def is_launchable(self, process):
     return is_launchable(self, process)