Exemple #1
0
 def test_get_process(self):
     # XXX This test might be superfluous.
     portal = self.portal
     alf = getToolByName(portal, 'workflow_manager')
     pid = get_random_id()
     alf.processes[pid] = Process(pid)
     process = alf.processes[pid]
     process.editable(ProcessVersion())
     process.update()
     current = process.current()
     self.assert_(IProcessVersion.providedBy(current))
Exemple #2
0
    def __call__(self, process_node):
        process = ProcessVersion()

        # Configure the process' simple attributes
        configure_attributes(process_node, process, self.attributes)

        # Import all activities
        for node in get_element_children(process_node):
            activity_importer = zope.component.getAdapter(
                process, IDOMImporter, name=node.nodeName)
            for activity in activity_importer(node):
                process[activity.getId()] = activity

        return [process]
Exemple #3
0
    def test_use_parallel_review_template(self):
        wftool = self.portal.workflow_manager
        wftool.processes['dummy'] = Process('dummy')
        wftool.processes["dummy"].editable(ProcessVersion())
        wftool.processes["dummy"].update()
        process = wftool.processes['dummy'].current()

        # Load form
        self.assertPublish("@@template-parallelreview", process)

        # Submit form
        self.assertEquals(0, len(process.objectIds()))
        self.assertPublish(
            "@@template-parallelreview?form.actions.apply=Save&form.reviews=3&form.title=Review",
            process)
        self.assertEquals(6, len(process.objectIds()))
Exemple #4
0
    def test_use_timelimit_template(self):
        wftool = self.portal.workflow_manager
        wftool.processes['dummy'] = Process('dummy')
        wftool.processes["dummy"].editable(ProcessVersion())
        wftool.processes["dummy"].update()
        process = wftool.processes['dummy'].current()

        # Load form
        self.assertPublish("@@template-timelimit", process)

        # Submit form
        self.assertEquals(0, len(process.objectIds()))
        self.assertPublish(
            "@@template-timelimit?form.actions.apply=Save&form.assignment=decision&form.assignment-empty-marker=1&form.title=Irgendwas",
            process)
        self.assertEquals(5, len(process.objectIds()))
Exemple #5
0
    def test_process_revert(self):
        self.portal['foo'] = Process('foo')
        # Acquisition wrapping
        process = self.portal['foo']
        self.assertRaises(Exception, process.revert)

        base_version = process.editable(ProcessVersion())
        self.assertRaises(Exception, process.revert)

        process.update()
        self.assertEquals(None, process.editable())
        process.revert()
        self.assertEquals(None, process.editable())

        new_version = process.editable(base_version.getId())
        process.revert()
        self.assertEquals(None, process.editable())
        process.revert()
        self.assertEquals(None, process.editable())
Exemple #6
0
    def test_canRenderWorkflow(self):
        request = zope.publisher.browser.TestRequest()
        pm = self.portal.workflow_manager
        pm.processes['asdf'] = Process('asdf')
        process = pm.processes["asdf"].editable(ProcessVersion())
        process.title = "test"

        editorview = Editor(process, request)
        add_activity = EditActivity(process, request).add

        add_activity('ntask')
        act1 = process.objectValues()[0]
        add_activity('ntask')
        act2 = list(set(process.objectValues()) - set([act1]))[0]

        # we should have two activities in this process
        self.assertEquals(2, len(process.objectIds()))
        self.assertEquals(False, editorview.canRenderWorkflow())

        # now connect those and we should be able to display a graph
        act1[Products.AlphaFlow.config.CHECKPOINT_START].activities += (
            act2.id, )
        self.assertEquals(True, editorview.canRenderWorkflow())
Exemple #7
0
    def test_definition_(self):
        # Creates a simple workflow
        portal = self.portal
        self._create_test_users()
        self.loginAsPortalOwner()

        wftool = getToolByName(portal, 'workflow_manager')

        # Create a new process definition
        wftool.processes["myProcess"] = Process('myProcess')
        wftool.processes["myProcess"].editable(ProcessVersion())
        wftool.processes["myProcess"].update()

        process = wftool.processes['myProcess'].current()

        process.setTitle("My demo process")
        process.setDescription("A process that demonstrates the new"
            "workflow tool")
        process.startActivity = ("write_document",)

        def add_activity(process, id, name):
            factory = zope.component.getUtility(IActivityClass, name=name)
            process[id] = factory()
            activity = process[id]
            activity.id = id
            return activity

        # "task" is a special kind of activity to ask people to do
        # something
        write_document = add_activity(process, "write_document", "ntask")
        cp_complete = ExitDefinition()
        cp_complete.activities = ("check_document", )
        cp_complete.id = "complete"
        write_document._setObject("complete", cp_complete)

        # "vote" is an activity, that asks people if something should
        # proceed or not
        check_document = add_activity(process, "check_document", "decision")
        check_document.decision_modus = 'all_yes'
        check_document.decision_notice = u'Decide something!'

        # Let's create some content
        portal.createObject("testdocument", "DummyContent")

        # Initialize the process
        doc = portal.testdocument
        # error on not existing process id
        self.assertRaises(AttributeError, doc.assignProcess, 'not existing processId')
        doc.assignProcess(wftool.processes['myProcess'].current())

        instance = doc.getInstance()

        instance.edit(write_document_assignees="author",
            write_document_task="Bitte eine" 
            "Pressemitteilung zum Thema Drogenpraevention 2004 schreiben",
            check_document_assignees=["editor1", "editor2"])

        controller = ILifeCycleController(instance)
        controller.start("testing")
        self.assertEquals(controller.state, "active")

        # Check for the correct error if an non-existing activity is created
        self.assertRaises(UnknownActivityError, instance.createWorkItems, ['nonexistent'], instance)

        wftool.processes["other_process"] = Process('other_process')
        wftool.processes["other_process"].editable(ProcessVersion())
        wftool.processes["other_process"].update()
        # If a process is already assigned, we can not assign another:
        self.assertRaises(Exception, doc.assignProcess,
                          wftool.processes['other_process'].current())
        new_instance = doc.getInstance()
        self.failUnless(instance.aq_base is new_instance.aq_base)

        self.login("author")
        write_document_wi = doc.getWorkItemsForCurrentUser()[0]
        # Test for instance.getWorkItems with optional activity_id parameter
        instance = doc.getInstance()
        self.assertEquals([], instance.getWorkItems(activity_id="michgibtsnich"))
        self.assertEquals([write_document_wi], 
                          instance.getWorkItems(activity_id="write_document"))

        write_document_wi.complete('complete')

        self.login("editor1")
        doc.getWorkItemsForCurrentUser()[0].accept()

        self.login("editor2")
        doc.getWorkItemsForCurrentUser()[0].accept()

        self.loginAsPortalOwner()
        self.assertEquals(0, len(instance.getWorkItems()))
        self.assertEquals(False, doc.hasInstanceAssigned())