def test_integration_object_events(self):
        """ Trigger every event of a objec at least one times
        and check the journalentries.
        """

        dossier1 = create(Builder('dossier'))
        dossier2 = create(Builder('dossier'))

        document = create(
            Builder('document').within(dossier1).titled(u'Document'))
        document2 = create(
            Builder('document').within(dossier2).titled(u'Document'))

        notify(
            ObjectMovedEvent(
                document,
                dossier1,
                'oldName',
                dossier2,
                'newName',
            ))
        self.check_annotation(
            dossier1,
            action_type='Object moved',
            action_title='Object moved: %s' % document.title_or_id(),
        )

        # Test that a normal ObjectAddedEvent does not result in an object
        # moved journal entry.
        notify(ObjectAddedEvent(document2))
        entry1 = get_journal_entry(dossier2, entry=-1)
        entry2 = get_journal_entry(dossier2, entry=-2)
        self.assertTrue(entry1.get('action').get('type') != 'Object moved')
        self.assertTrue(entry2.get('action').get('type') != 'Object moved')

        notify(
            ObjectWillBeMovedEvent(
                document,
                dossier1,
                'oldName',
                dossier2,
                'newName',
            ))
        self.check_annotation(dossier1,
                              action_type='Object cut',
                              action_title='Object cut: %s' %
                              document.title_or_id())

        # Here we don't have a journal-entry
        length = get_journal_length(dossier1)
        notify(ObjectWillBeAddedEvent(
            document,
            dossier2,
            'newName',
        ))
        self.assertTrue(length == get_journal_length(dossier1))
Beispiel #2
0
    def test_integration_document_events(self):
        """ Trigger every event of a document at least one times
        and check the journalentries.

        Attention: we always have to check the parent.
        If we add a document to a dossier, the dossier is modified.
        So on the dossiers journal there are two new entries, one for the new
        document and one for the changed dossier. We just have to check the
        entry of the new document on the dossiers journal
        """
        comment = 'my comment'

        dossier = create(Builder('dossier'))

        # Add-Event
        document = create(Builder('document')
                          .within(dossier)
                          .with_dummy_content()
                          .titled(u'Doc\xfcment'))

        self.check_object_added(
            document,
            'Document added',
            'Document added: %s' % document.title_or_id(),
            dossier)

        # Object Checked-Out-Event
        notify(ObjectCheckedOutEvent(document, comment))
        self.check_document_checkedout(document, comment)

        # Object Checked-In-Event
        notify(ObjectCheckedInEvent(document, comment))
        self.check_document_checkedin(document, comment)

        # Object Checked-Out-Canceled-Event
        notify(ObjectCheckoutCanceledEvent(document))
        self.check_document_checkoutcanceled(document)

        # Object Reverted-To-Version-Event with fail
        length = get_journal_length(document)
        notify(ObjectRevertedToVersion(document, '', ''))
        self.assertTrue(length == get_journal_length(document))

        # Object Reverted-To-Version-Event
        notify(ObjectRevertedToVersion(document, 'v1', 'v1'))
        self.check_document_revertedtoversion(document)

        # Object Sent Document Event
        notify(DocumentSent(dossier, TEST_USER_ID, '*****@*****.**',
                            'test mail', 'Mymessage', [document]))
        self.check_document_sent(dossier, document)

        # Object downloaded file-copy Event
        notify(FileCopyDownloadedEvent(document))
        self.check_document_copy_downloaded(document)
    def test_integration_object_events(self):
        """ Trigger every event of a objec at least one times
        and check the journalentries.
        """
        portal = self.layer['portal']

        dossier1 = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd1')
        dossier2 = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd2')

        document = createContentInContainer(
            dossier1, 'opengever.document.document', 'doc1', title='Document')

        document2 = createContentInContainer(
            dossier2, 'opengever.document.document', 'doc2', title='Document2')

        notify(ObjectMovedEvent(
            document,
            dossier1,
            'oldName',
            dossier2,
            'newName', ))
        self.check_annotation(
            dossier1,
            action_type='Object moved',
            action_title='Object moved: %s' % document.title_or_id(), )

        # Test that a normal ObjectAddedEvent does not result in an object
        # moved journal entry.
        notify(ObjectAddedEvent(document2))
        entry1 = get_journal_entry(dossier2, entry=-1)
        entry2 = get_journal_entry(dossier2, entry=-2)
        self.assertTrue(entry1.get('action').get('type') != 'Object moved')
        self.assertTrue(entry2.get('action').get('type') != 'Object moved')

        notify(ObjectWillBeMovedEvent(
            document,
            dossier1,
            'oldName',
            dossier2,
            'newName', ))
        self.check_annotation(
                dossier1,
                action_type='Object cut',
                action_title='Object cut: %s' % document.title_or_id(), )

        # Here we don't have a journal-entry
        length = get_journal_length(dossier1)
        notify(ObjectWillBeAddedEvent(
            document,
            dossier2,
            'newName', ))
        self.assertTrue(length == get_journal_length(dossier1))
Beispiel #4
0
    def test_integration_object_events(self):
        """ Trigger every event of a objec at least one times
        and check the journalentries.
        """

        dossier1 = create(Builder('dossier'))
        dossier2 = create(Builder('dossier'))

        document = create(Builder('document')
                          .within(dossier1)
                          .titled(u'Document'))
        document2 = create(Builder('document')
                           .within(dossier2)
                           .titled(u'Document'))

        notify(ObjectMovedEvent(
            document,
            dossier1,
            'oldName',
            dossier2,
            'newName', ))
        self.check_annotation(
            dossier1,
            action_type='Object moved',
            action_title='Object moved: %s' % document.title_or_id(), )

        # Test that a normal ObjectAddedEvent does not result in an object
        # moved journal entry.
        notify(ObjectAddedEvent(document2))
        entry1 = get_journal_entry(dossier2, entry=-1)
        entry2 = get_journal_entry(dossier2, entry=-2)
        self.assertTrue(entry1.get('action').get('type') != 'Object moved')
        self.assertTrue(entry2.get('action').get('type') != 'Object moved')

        notify(ObjectWillBeMovedEvent(
            document,
            dossier1,
            'oldName',
            dossier2,
            'newName', ))
        self.check_annotation(
            dossier1,
            action_type='Object cut',
            action_title='Object cut: %s' % document.title_or_id())

        # Here we don't have a journal-entry
        length = get_journal_length(dossier1)
        notify(ObjectWillBeAddedEvent(
            document,
            dossier2,
            'newName', ))
        self.assertTrue(length == get_journal_length(dossier1))
Beispiel #5
0
    def test_files_with_custom_properties_are_not_updated(self):
        self.document = create(
            Builder('document')
            .within(self.dossier)
            .titled("Document with custom props")
            .with_asset_file('with_custom_properties.docx'))

        expected_doc_properties = [('Test', 'Peter',)]

        writer = DocPropertyWriter(self.document)
        writer.update_doc_properties(only_existing=True)
        with TemporaryDocFile(self.document.file) as tmpfile:
            properties = read_properties(tmpfile.path)
            self.assertItemsEqual(expected_doc_properties, properties)

        self.assertEqual(1, get_journal_length(self.document))
        entry = get_journal_entry(self.document)
        self.assertNotEqual(entry['action']['type'], DOC_PROPERTIES_UPDATED)
Beispiel #6
0
    def test_files_with_custom_properties_are_not_updated(self):
        self.document = create(
            Builder('document').within(
                self.dossier).titled("Document with custom props").
            with_asset_file('with_custom_properties.docx'))

        expected_doc_properties = [(
            'Test',
            'Peter',
        )]

        writer = DocPropertyWriter(self.document)
        writer.update_doc_properties(only_existing=True)
        with TemporaryDocFile(self.document.file) as tmpfile:
            properties = read_properties(tmpfile.path)
            self.assertItemsEqual(expected_doc_properties, properties)

        self.assertEqual(1, get_journal_length(self.document))
        entry = get_journal_entry(self.document)
        self.assertNotEqual(entry['action']['type'], DOC_PROPERTIES_UPDATED)
Beispiel #7
0
    def test_files_with_custom_properties_are_not_updated(self):
        self.login(self.regular_user)
        self.with_asset_file('with_custom_properties.docx')

        expected_doc_properties = [('Test', 'Peter',)]

        (
            DocPropertyWriter(self.document)
            .update_doc_properties(only_existing=True)
            )

        with TemporaryDocFile(self.document.file) as tmpfile:
            properties = read_properties(tmpfile.path)
            self.assertItemsEqual(expected_doc_properties, properties)

        self.assertEqual(1, get_journal_length(self.document))

        entry = get_journal_entry(self.document)

        self.assertNotEqual(entry['action']['type'], DOC_PROPERTIES_UPDATED)
    def test_integration_object_events(self):
        """ Trigger every event of a objec at least one times
        and check the journalentries.
        """
        portal = self.layer['portal']

        dossier1 = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd1')
        dossier2 = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd2')

        document = createContentInContainer(dossier1,
                                            'opengever.document.document',
                                            'doc1',
                                            title='Document')

        document2 = createContentInContainer(dossier2,
                                             'opengever.document.document',
                                             'doc2',
                                             title='Document2')

        notify(
            ObjectMovedEvent(
                document,
                dossier1,
                'oldName',
                dossier2,
                'newName',
            ))
        self.check_annotation(
            dossier1,
            action_type='Object moved',
            action_title='Object moved: %s' % document.title_or_id(),
        )

        # Test that a normal ObjectAddedEvent does not result in an object
        # moved journal entry.
        notify(ObjectAddedEvent(document2))
        entry1 = get_journal_entry(dossier2, entry=-1)
        entry2 = get_journal_entry(dossier2, entry=-2)
        self.assertTrue(entry1.get('action').get('type') != 'Object moved')
        self.assertTrue(entry2.get('action').get('type') != 'Object moved')

        notify(
            ObjectWillBeMovedEvent(
                document,
                dossier1,
                'oldName',
                dossier2,
                'newName',
            ))
        self.check_annotation(
            dossier1,
            action_type='Object cut',
            action_title='Object cut: %s' % document.title_or_id(),
        )

        # Here we don't have a journal-entry
        length = get_journal_length(dossier1)
        notify(ObjectWillBeAddedEvent(
            document,
            dossier2,
            'newName',
        ))
        self.assertTrue(length == get_journal_length(dossier1))
    def test_integration_document_events(self):
        """ Trigger every event of a document at least one times
        and check the journalentries.

        Attention: we always have to check the parent.
        If we add a document to a dossier, the dossier is modified.
        So on the dossiers journal there are two new entries, one for the new
        document and one for the changed dossier. We just have to check the
        entry of the new document on the dossiers journal
        """
        portal = self.layer['portal']
        comment = 'my comment'

        registry = getUtility(IRegistry)
        proxy = registry.forInterface(IClientConfiguration)
        proxy.client_id = u'Test'
        dossier = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd1')

        # Add-Event
        document = createContentInContainer(dossier,
                                            'opengever.document.document',
                                            'd1',
                                            title=u'Doc\xfcment')

        self.check_object_added(document, 'Document added',
                                'Document added: %s' % document.title_or_id(),
                                dossier)

        # Modified-Event - nothing changed
        length_document = get_journal_length(document)
        length_dossier = get_journal_length(dossier)

        notify(ObjectModifiedEvent(document))

        self.assertTrue(length_document == get_journal_length(document))
        self.assertTrue(length_dossier == get_journal_length(dossier))

        # Modified-Event - file changed
        notify(ObjectModifiedEvent(document, Attributes(Interface, 'file')))
        self.check_document_modified(document, dossier, 'file')

        # Modified-Event - meta changed
        notify(ObjectModifiedEvent(document, Attributes(Interface, 'meta')))
        self.check_document_modified(document, dossier, 'meta')

        # Modified-Event - file and meta changed
        notify(
            ObjectModifiedEvent(document, Attributes(Interface, 'file',
                                                     'meta')))
        self.check_document_modified(document, dossier, 'file_meta')

        # Get the workflow for the document to test the ActionSucceededEvent
        wftool = getToolByName(document, 'portal_workflow')
        workflow = wftool.get('simple_publication_workflow')

        # Action-Succeeded-Event with skipped transaction
        length = get_journal_length(document)
        notify(
            ActionSucceededEvent(
                document,
                workflow,
                'check_out',
                'checked_out',
            ))
        self.assertTrue(length == get_journal_length(document))

        # Action-Succeeded-Event
        notify(
            ActionSucceededEvent(
                document,
                workflow,
                'publish',
                'published',
            ))
        self.check_document_actionsucceeded(document)

        # Object Checked-Out-Event
        notify(ObjectCheckedOutEvent(document, comment))
        self.check_document_checkedout(document, comment)

        # Object Checked-In-Event
        notify(ObjectCheckedInEvent(document, comment))
        self.check_document_checkedin(document, comment)

        # Object Checked-Out-Canceled-Event
        notify(ObjectCheckoutCanceledEvent(document))
        self.check_document_checkoutcanceled(document)

        # Object Reverted-To-Version-Event with fail
        length = get_journal_length(document)
        notify(ObjectRevertedToVersion(document, '', ''))
        self.assertTrue(length == get_journal_length(document))

        # Object Reverted-To-Version-Event
        notify(ObjectRevertedToVersion(document, 'v1', 'v1'))
        self.check_document_revertedtoversion(document)

        # Object Sent Document Event
        notify(
            DocumentSent(dossier, TEST_USER_ID, '*****@*****.**', 'test mail',
                         'Mymessage', [document]))
        self.check_document_sent(dossier, document)

        # Object downloaded file-copy Event
        notify(FileCopyDownloadedEvent(document))
        self.check_document_copy_downloaded(document)
    def test_integration_document_events(self):
        """ Trigger every event of a document at least one times
        and check the journalentries.

        Attention: we always have to check the parent.
        If we add a document to a dossier, the dossier is modified.
        So on the dossiers journal there are two new entries, one for the new
        document and one for the changed dossier. We just have to check the
        entry of the new document on the dossiers journal
        """
        portal = self.layer['portal']
        comment = 'my comment'

        registry = getUtility(IRegistry)
        proxy = registry.forInterface(IClientConfiguration)
        proxy.client_id = u'Test'
        dossier = createContentInContainer(
            portal, 'opengever.dossier.businesscasedossier', 'd1')

        # Add-Event
        document = createContentInContainer(
            dossier, 'opengever.document.document', 'd1', title=u'Doc\xfcment')

        self.check_object_added(
            document,
            'Document added',
            'Document added: %s' % document.title_or_id(),
            dossier)

        # Modified-Event - nothing changed
        length_document = get_journal_length(document)
        length_dossier = get_journal_length(dossier)

        notify(ObjectModifiedEvent(document))

        self.assertTrue(length_document == get_journal_length(document))
        self.assertTrue(length_dossier == get_journal_length(dossier))

        # Modified-Event - file changed
        notify(ObjectModifiedEvent(document, Attributes(Interface, 'file')))
        self.check_document_modified(document, dossier, 'file')

        # Modified-Event - meta changed
        notify(ObjectModifiedEvent(document, Attributes(Interface, 'meta')))
        self.check_document_modified(document, dossier, 'meta')

        # Modified-Event - file and meta changed
        notify(ObjectModifiedEvent(
            document, Attributes(Interface, 'file', 'meta')))
        self.check_document_modified(document, dossier, 'file_meta')

        # Get the workflow for the document to test the ActionSucceededEvent
        wftool = getToolByName(document, 'portal_workflow')
        workflow = wftool.get('simple_publication_workflow')

        # Action-Succeeded-Event with skipped transaction
        length = get_journal_length(document)
        notify(ActionSucceededEvent(
            document, workflow, 'check_out', 'checked_out', ))
        self.assertTrue(length == get_journal_length(document))

        # Action-Succeeded-Event
        notify(ActionSucceededEvent(
            document, workflow, 'publish', 'published', ))
        self.check_document_actionsucceeded(document)

        # Object Checked-Out-Event
        notify(ObjectCheckedOutEvent(document, comment))
        self.check_document_checkedout(document, comment)

        # Object Checked-In-Event
        notify(ObjectCheckedInEvent(document, comment))
        self.check_document_checkedin(document, comment)

        # Object Checked-Out-Canceled-Event
        notify(ObjectCheckoutCanceledEvent(document))
        self.check_document_checkoutcanceled(document)

        # Object Reverted-To-Version-Event with fail
        length = get_journal_length(document)
        notify(ObjectRevertedToVersion(document, '', ''))
        self.assertTrue(length == get_journal_length(document))

        # Object Reverted-To-Version-Event
        notify(ObjectRevertedToVersion(document, 'v1', 'v1'))
        self.check_document_revertedtoversion(document)

        # Object Sent Document Event
        notify(DocumentSent(dossier, TEST_USER_ID, '*****@*****.**', 'test mail', 'Mymessage', [document]))
        self.check_document_sent(dossier, document)

        # Object downloaded file-copy Event
        notify(FileCopyDownloadedEvent(document))
        self.check_document_copy_downloaded(document)