예제 #1
0
    def test_queues_bumblebee_storing_after_revert_to_previous_version(self):
        dossier = create(Builder('dossier'))
        document = create(Builder('document')
                          .within(dossier)
                          .attach_file_containing(
                              'foo', u'example.docx'))
        create_document_version(document, 1,
                                data=bumblebee_asset('example.docx').bytes())
        create_document_version(document, 2)
        queue = get_queue()
        queue.reset()

        manager = getMultiAdapter((document, self.portal.REQUEST),
                                  ICheckinCheckoutManager)
        manager.revert_to_version(1)

        self.assertEquals(1, len(queue), 'Expected 1 job in the queue.')
        job, = queue.queue

        self.assertDictEqual(
            {'application': 'local',
             'file_url': ('http://nohost/plone/bumblebee_download' +
                          '?checksum={}'.format(DOCX_CHECKSUM) +
                          '&uuid={}'.format(IUUID(document))),
             'salt': IUUID(document),
             'checksum': DOCX_CHECKSUM,
             'deferred': False,
             'url': '/plone/dossier-1/document-1/bumblebee_trigger_storing'},
            job)
예제 #2
0
    def test_outdated_document_can_be_updated(self, browser):
        self.login(self.meeting_user, browser)

        # No initial versions anymore, so have to do two versions
        create_document_version(self.document, 0)
        create_document_version(self.document, 1)

        browser.open(self.document, view='tabbedview_view-overview')

        browser.find('Update document in proposal').click()
        browser.find('Submit Attachments').click()

        self.assertEqual(
            [
                (
                    u'A new submitted version of document'
                    u' Vertr\xe4gsentwurf has been created.'
                    ),
                ],
            info_messages(),
            )

        self.assert_submitted_document_created(
            self.proposal,
            self.document,
            submitted_version=1,
            )
예제 #3
0
    def test_archeologist_returns_modifyable_persistent_reference(self):
        dossier = create(Builder('dossier'))
        document = create(Builder('document')
                          .within(dossier)
                          .attach_file_containing(
                              bumblebee_asset('example.docx').bytes(),
                              u'example.docx'))
        create_document_version(document, version_id=1)
        create_document_version(document, version_id=2)

        repository = api.portal.get_tool('portal_repository')

        archived_obj = Archeologist(
            document, repository.retrieve(document, selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertNotIn(TEST_ANNOTATION_KEY, annotations)
        annotations[TEST_ANNOTATION_KEY] = 'can touch this!'
        archived_obj.some_attr = 'can touch this!'

        transaction.commit()

        archived_obj = Archeologist(
            document, repository.retrieve(document, selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertIn(TEST_ANNOTATION_KEY, annotations)
        self.assertEqual('can touch this!', annotations[TEST_ANNOTATION_KEY])
        self.assertEqual('can touch this!', archived_obj.some_attr)
예제 #4
0
    def test_warning_only_rendered_on_old_version(self, browser):
        self.login(self.regular_user, browser)
        create_document_version(self.document, version_id=0)

        browser.open(self.document, view='bumblebee-overlay-document')
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=0',
            )
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        create_document_version(self.document, version_id=1)

        browser.open(self.document, view='bumblebee-overlay-document')
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=1',
            )
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=0',
            )
        self.assertTrue(browser.css('.info-viewlets .portalMessage.warning'))
    def test_warning_only_rendered_on_old_version(self, browser):
        self.login(self.regular_user, browser)
        create_document_version(self.document, version_id=0)

        browser.open(self.document, view='bumblebee-overlay-document')
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=0',
            )
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        create_document_version(self.document, version_id=1)

        browser.open(self.document, view='bumblebee-overlay-document')
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=1',
            )
        self.assertFalse(browser.css('.info-viewlets .portalMessage.warning'))

        browser.open(
            self.document,
            view='bumblebee-overlay-document?version_id=0',
            )
        self.assertTrue(browser.css('.info-viewlets .portalMessage.warning'))
 def _create_doc_with_versions(self, n=3):
     doc = self._create_doc()
     for version_id in range(1, n + 1):
         create_document_version(doc,
                                 version_id,
                                 comment=u'Kommentar mit Uml\xe4ut')
     return doc
예제 #7
0
    def test_queues_bumblebee_storing_after_revert_to_previous_version(self):
        dossier = create(Builder('dossier'))
        document = create(
            Builder('document').within(dossier).attach_file_containing(
                'foo', u'example.docx'))
        create_document_version(document,
                                1,
                                data=bumblebee_asset('example.docx').bytes())
        create_document_version(document, 2)
        queue = get_queue()
        queue.reset()

        manager = getMultiAdapter((document, self.portal.REQUEST),
                                  ICheckinCheckoutManager)
        manager.revert_to_version(1)

        self.assertEquals(1, len(queue), 'Expected 1 job in the queue.')
        job, = queue.queue

        self.assertDictEqual(
            {
                'application':
                'local',
                'file_url': ('http://nohost/plone/bumblebee_download' +
                             '?checksum={}'.format(DOCX_CHECKSUM) +
                             '&uuid={}'.format(IUUID(document))),
                'salt':
                IUUID(document),
                'checksum':
                DOCX_CHECKSUM,
                'deferred':
                False,
                'url':
                '/plone/dossier-1/document-1/bumblebee_trigger_storing'
            }, job)
예제 #8
0
    def test_outdated_document_can_be_updated(self, browser):
        self.login(self.meeting_user, browser)

        # No initial versions anymore, so have to do two versions
        create_document_version(self.document, 0)
        create_document_version(self.document, 1)

        browser.open(self.document, view='tabbedview_view-overview')

        browser.find('Update document in proposal').click()
        browser.find('Submit Attachments').click()

        self.assertEqual(
            [
                (u'A new submitted version of document'
                 u' Vertr\xe4gsentwurf has been created.'),
            ],
            info_messages(),
        )

        self.assert_submitted_document_created(
            self.proposal,
            self.document,
            submitted_version=1,
        )
    def test_actions_with_versioned_document(self, browser):
        dossier = create(Builder('dossier'))
        document = create(
            Builder('document').within(dossier).attach_file_containing(
                bumblebee_asset('example.docx').bytes(), u'example.docx'))

        create_document_version(document, version_id=1)
        transaction.commit()

        browser.login()
        browser.open(document, view="bumblebee-overlay-document?version_id=1")

        self.assertEqual(['Download copy', 'Revert document'],
                         browser.css('.file-action-buttons a').text)
예제 #10
0
    def setUp(self):
        super(TestReverting, self).setUp()
        self.dossier = create(Builder('dossier'))
        self.document = create(Builder('document')
                               .having(document_date=date(2014, 1, 1))
                               .within(self.dossier)
                               .attach_file_containing(
                                   u"INITIAL VERSION DATA", u"somefile.txt"))

        create_document_version(self.document, 1)
        create_document_version(self.document, 2)
        transaction.commit()

        self.manager = getMultiAdapter(
            (self.document, self.portal.REQUEST), ICheckinCheckoutManager)
예제 #11
0
    def setUp(self):
        super(TestReverting, self).setUp()
        self.dossier = create(Builder("dossier"))
        self.document = create(
            Builder("document")
            .having(document_date=date(2014, 1, 1))
            .within(self.dossier)
            .attach_file_containing(u"INITIAL VERSION DATA", u"somefile.txt")
        )

        create_document_version(self.document, 1)
        create_document_version(self.document, 2)
        transaction.commit()

        self.manager = getMultiAdapter((self.document, self.portal.REQUEST), ICheckinCheckoutManager)
class TestVersionsTab(BaseVersionsTab):
    @browsing
    def test_dates_are_formatted_correctly(self, browser):
        with freeze(datetime(2015, 01, 28, 12, 00)):
            doc = self._create_doc()
        with freeze(datetime(2015, 01, 28, 18, 30)):
            create_document_version(doc, 1)
예제 #13
0
    def test_actions_with_versioned_document(self, browser):
        dossier = create(Builder('dossier'))
        document = create(Builder('document')
                          .within(dossier)
                          .attach_file_containing(
                              bumblebee_asset('example.docx').bytes(),
                              u'example.docx'))

        create_document_version(document, version_id=1)
        transaction.commit()

        browser.login().visit(document, view="bumblebee-overlay-document?version_id=1")

        self.assertEqual(
            ['Revert document', 'Download copy'],
            browser.css('.file-actions a').text)
예제 #14
0
    def test_actions_with_versioned_document(self, browser):
        self.login(self.regular_user, browser)
        create_document_version(self.document, version_id=0)

        browser.open(
            self.document,
            view="bumblebee-overlay-document?version_id=0",
            )

        self.assertEqual(
            [
                'Download copy',
                'Revert document',
                ],
            browser.css('.file-action-buttons a').text,
            )
예제 #15
0
    def test_queues_bumblebee_storing_after_revert_to_previous_version(self):
        self.login(self.dossier_responsible)

        self.subdocument.update_file(
            'foo',
            content_type='text/plain',
            filename=u'foo.txt',
        )

        create_document_version(
            self.subdocument,
            1,
            data=bumblebee_asset('example.docx').bytes(),
        )

        create_document_version(self.subdocument, 2)

        queue = get_queue()
        queue.reset()

        manager = self.get_checkout_manager(self.subdocument)
        manager.revert_to_version(1)

        self.assertEquals(1, len(queue), 'Expected 1 job in the queue.')

        expected_job = {
            'application':
            'local',
            'file_url':
            ('http://nohost/plone/bumblebee_download?checksum={}&uuid={}'.
             format(DOCX_CHECKSUM, IUUID(self.subdocument))),
            'salt':
            IUUID(self.subdocument),
            'checksum':
            DOCX_CHECKSUM,
            'deferred':
            False,
            'url':
            ('/plone/ordnungssystem/fuhrung/vertrage-und-vereinbarungen'
             '/dossier-1/dossier-2/document-22/bumblebee_trigger_storing'),
        }

        found_job, = queue.queue

        self.assertDictEqual(expected_job, found_job)
예제 #16
0
    def test_download_versioned_copy_creates_journal_entries_with_versions_in_title(
            self, browser):  # noqa
        browser.login().open(self.document, view='tabbedview_view-versions')
        browser.css('a.function-download-copy').first.click()
        browser.find('label_download').click()

        self.assert_download_journal_entry_created(self.document,
                                                   u'Download copy version 1')

        create_document_version(self.document, 2)
        transaction.commit()

        browser.login().open(self.document, view='tabbedview_view-versions')
        browser.css('a.function-download-copy').first.click()
        browser.find('label_download').click()

        self.assert_download_journal_entry_created(self.document,
                                                   u'Download copy version 2')
예제 #17
0
    def setUp(self):
        super(TestReverting, self).setUp()
        self.dossier = create(Builder('dossier'))
        self.document = create(Builder('document')
                               .having(document_date=self.document_date)
                               .within(self.dossier)
                               .attach_file_containing(
                                   u"INITIAL VERSION DATA", u"somefile.txt"))

        # trigger initial version creation
        self.document.file = NamedBlobFile(
            data='New conent', filename=u'test.txt')

        create_document_version(self.document, 1)
        create_document_version(self.document, 2)
        transaction.commit()

        self.manager = getMultiAdapter(
            (self.document, self.portal.REQUEST), ICheckinCheckoutManager)
예제 #18
0
    def test_download_versioned_copy_creates_journal_entries_with_versions_in_title(self, browser):  # noqa
        browser.login().open(self.document, view='tabbedview_view-versions')
        browser.css('a.function-download-copy').first.click()
        browser.find('label_download').click()

        self.assert_download_journal_entry_created(
            self.document,
            u'Download copy version 1')

        create_document_version(self.document, 2)
        transaction.commit()

        browser.login().open(self.document, view='tabbedview_view-versions')
        browser.css('a.function-download-copy').first.click()
        browser.find('label_download').click()

        self.assert_download_journal_entry_created(
            self.document,
            u'Download copy version 2')
예제 #19
0
    def setUp(self):
        super(TestReverting, self).setUp()
        self.dossier = create(Builder('dossier'))
        self.document = create(Builder('document')
                               .having(document_date=self.document_date)
                               .within(self.dossier)
                               .attach_file_containing(
                                   u"INITIAL VERSION DATA", u"somefile.txt"))

        # trigger initial version creation
        self.document.file = NamedBlobFile(
            data='New conent', filename=u'test.txt')

        create_document_version(self.document, 1)
        create_document_version(self.document, 2)
        transaction.commit()

        self.manager = getMultiAdapter(
            (self.document, self.portal.REQUEST), ICheckinCheckoutManager)
예제 #20
0
    def test_archeologist_returns_modifyable_persistent_reference(self):
        self.login(self.regular_user)

        create_document_version(self.document, version_id=1)
        create_document_version(self.document, version_id=2)

        repository = api.portal.get_tool('portal_repository')

        archived_obj = Archeologist(
            self.document, repository.retrieve(self.document, selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertNotIn(TEST_ANNOTATION_KEY, annotations)
        annotations[TEST_ANNOTATION_KEY] = 'can touch this!'
        archived_obj.some_attr = 'can touch this!'

        archived_obj = Archeologist(
            self.document, repository.retrieve(self.document, selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertIn(TEST_ANNOTATION_KEY, annotations)
        self.assertEqual('can touch this!', annotations[TEST_ANNOTATION_KEY])
        self.assertEqual('can touch this!', archived_obj.some_attr)
예제 #21
0
 def test_bumblebee_overlay_renders_comments_correctly_on_versioned_documents(self, browser):
     self.login(self.regular_user, browser)
     create_document_version(self.document, version_id=0)
     getMultiAdapter((self.document, self.request), ICheckinCheckoutManager).checkout()
     browser.open(
         self.document.absolute_url() + '/@checkin',
         method='POST',
         headers={'Accept': 'application/json'},
         )
     getMultiAdapter((self.document, self.request), ICheckinCheckoutManager).checkout()
     browser.open(
         self.document.absolute_url() + '/@checkin',
         data='{"comment": "Foo bar."}',
         method='POST',
         headers={'Accept': 'application/json', 'Content-Type': 'application/json'},
         )
     browser.open(self.document, view='bumblebee-overlay-document?version_id=0')
     self.assertIn('Checkin comment: This is Version 0', browser.css('.metadata tr').text)
     browser.open(self.document, view='bumblebee-overlay-document?version_id=1')
     self.assertNotIn('Checkin comment:', browser.css('.metadata .title').text)
     browser.open(self.document, view='bumblebee-overlay-document?version_id=2')
     self.assertIn('Checkin comment: Foo bar.', browser.css('.metadata tr').text)
 def test_bumblebee_overlay_renders_comments_correctly_on_versioned_documents(self, browser):
     self.login(self.regular_user, browser)
     create_document_version(self.document, version_id=0)
     getMultiAdapter((self.document, self.request), ICheckinCheckoutManager).checkout()
     browser.open(
         self.document.absolute_url() + '/@checkin',
         method='POST',
         headers={'Accept': 'application/json'},
         )
     getMultiAdapter((self.document, self.request), ICheckinCheckoutManager).checkout()
     browser.open(
         self.document.absolute_url() + '/@checkin',
         data='{"comment": "Foo bar."}',
         method='POST',
         headers={'Accept': 'application/json', 'Content-Type': 'application/json'},
         )
     browser.open(self.document, view='bumblebee-overlay-document?version_id=0')
     self.assertIn('Checkin comment: This is Version 0', browser.css('.metadata tr').text)
     browser.open(self.document, view='bumblebee-overlay-document?version_id=1')
     self.assertNotIn('Checkin comment:', browser.css('.metadata .title').text)
     browser.open(self.document, view='bumblebee-overlay-document?version_id=2')
     self.assertIn('Checkin comment: Foo bar.', browser.css('.metadata tr').text)
예제 #23
0
    def test_archeologist_returns_modifyable_persistent_reference(self):
        self.login(self.regular_user)

        create_document_version(self.document, version_id=1)
        create_document_version(self.document, version_id=2)

        repository = api.portal.get_tool('portal_repository')

        archived_obj = Archeologist(
            self.document, repository.retrieve(self.document,
                                               selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertNotIn(TEST_ANNOTATION_KEY, annotations)
        annotations[TEST_ANNOTATION_KEY] = 'can touch this!'
        archived_obj.some_attr = 'can touch this!'

        archived_obj = Archeologist(
            self.document, repository.retrieve(self.document,
                                               selector=1)).excavate()
        annotations = IAnnotations(archived_obj)
        self.assertIn(TEST_ANNOTATION_KEY, annotations)
        self.assertEqual('can touch this!', annotations[TEST_ANNOTATION_KEY])
        self.assertEqual('can touch this!', archived_obj.some_attr)
예제 #24
0
 def test_revert_does_not_change_document_date(self):
     with freeze(datetime(2015, 01, 28, 12, 00)):
         create_document_version(self.document, 3)
예제 #25
0
 def test_resets_document_date_to_reverted_version(self):
     with freeze(datetime(2015, 01, 28, 12, 00)):
         create_document_version(self.document, 3)
예제 #26
0
 def test_dates_are_formatted_correctly(self, browser):
     with PDFConverterAvailability(False):
         with freeze(datetime(2015, 01, 28, 12, 00)):
             doc = self._create_doc()
         with freeze(datetime(2015, 01, 28, 18, 30)):
             create_document_version(doc, 1)
예제 #27
0
 def _create_doc_with_versions(self, n=3):
     doc = self._create_doc()
     for version_id in range(1, n + 1):
         create_document_version(doc, version_id)
     return doc
예제 #28
0
 def test_revert_does_not_change_document_date(self):
     with freeze(datetime(2015, 01, 28, 12, 00)):
         create_document_version(self.document, 3)
예제 #29
0
 def _create_doc_with_versions(self, n=3):
     doc = self._create_doc()
     for version_id in range(1, n + 1):
         create_document_version(doc, version_id)
     return doc
예제 #30
0
 def test_resets_document_date_to_reverted_version(self):
     with freeze(datetime(2015, 01, 28, 12, 00)):
         create_document_version(self.document, 3)
예제 #31
0
 def test_dates_are_formatted_correctly(self, browser):
     with PDFConverterAvailability(False):
         with freeze(datetime(2015, 01, 28, 12, 00)):
             doc = self._create_doc()
         with freeze(datetime(2015, 01, 28, 18, 30)):
             create_document_version(doc, 1)
    def test_render_download_link(self, browser):
        self.login(self.regular_user, browser)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        create_document_version(self.document, version_id=0)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=0',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        create_document_version(self.document, version_id=1)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=0',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertIn(
            'version_id=0',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=1',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )
 def test_bumblebee_overlay_renders_comment(self, browser):
     self.login(self.regular_user, browser)
     create_document_version(self.document, version_id=0)
     browser.open(self.document, view='bumblebee-overlay-listing')
     self.assertIn('Checkin comment: This is Version 0', browser.css('.metadata tr').text)
예제 #34
0
 def test_bumblebee_overlay_renders_comment(self, browser):
     self.login(self.regular_user, browser)
     create_document_version(self.document, version_id=0)
     browser.open(self.document, view='bumblebee-overlay-listing')
     self.assertIn('Checkin comment: This is Version 0', browser.css('.metadata tr').text)
예제 #35
0
    def test_render_download_link(self, browser):
        self.login(self.regular_user, browser)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        create_document_version(self.document, version_id=0)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=0',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        create_document_version(self.document, version_id=1)

        browser.open(self.document, view='bumblebee-overlay-listing')
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=0',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertIn(
            'version_id=0',
            download_link,
            )

        browser.open(
            self.document,
            view='bumblebee-overlay-listing?version_id=1',
            )
        download_link = browser.css('#action-download')[0].get('href')

        self.assertNotIn(
            'version_id',
            download_link,
            )
예제 #36
0
 def _create_doc_with_versions(self, n=3):
     doc = self._create_doc()
     for version_id in range(1, n + 1):
         create_document_version(doc, version_id,
                                 comment=u'Kommentar mit Uml\xe4ut')
     return doc