def test_pdf_conversion_job_is_queued_for_every_document(self):
        api.portal.set_registry_record('archival_file_conversion_enabled',
                                       True,
                                       interface=IDossierResolveProperties)

        doc1 = create(
            Builder('document').within(self.dossier).attach_file_containing(
                bumblebee_asset('example.docx').bytes(), u'example.docx'))
        create(
            Builder('document').within(self.dossier).attach_file_containing(
                bumblebee_asset('example.docx').bytes(), u'example.docx'))

        get_queue().reset()
        with RequestsSessionMock.installed():
            api.content.transition(obj=self.dossier,
                                   transition='dossier-transition-resolve')
            transaction.commit()

            self.assertEquals(2, len(get_queue().queue))
            self.assertDictContainsSubset(
                {
                    'callback_url':
                    '{}/archival_file_conversion_callback'.format(
                        doc1.absolute_url()),
                    'file_url':
                    'http://nohost/plone/bumblebee_download?checksum={}&uuid={}'
                    .format(DOCX_CHECKSUM, IUUID(doc1)),
                    'target_format':
                    'pdf/a',
                    'url':
                    '/plone/dossier-1/document-1/bumblebee_trigger_conversion'
                },
                get_queue().queue[0])
Example #2
0
    def test_pdf_conversion_job_is_queued_for_every_document(self):
        api.portal.set_registry_record(
            'archival_file_conversion_enabled', True,
            interface=IDossierResolveProperties)

        doc1 = create(Builder('document')
                      .within(self.dossier)
                      .attach_file_containing(
                          bumblebee_asset('example.docx').bytes(),
                          u'example.docx'))
        create(Builder('document')
               .within(self.dossier)
               .attach_file_containing(
                   bumblebee_asset('example.docx').bytes(),
                   u'example.docx'))

        get_queue().reset()
        with RequestsSessionMock.installed():
            api.content.transition(obj=self.dossier,
                                   transition='dossier-transition-resolve')
            transaction.commit()

            self.assertEquals(2, len(get_queue().queue))
            self.assertDictContainsSubset(
                {'callback_url': '{}/archival_file_conversion_callback'.format(
                    doc1.absolute_url()),
                 'file_url': 'http://nohost/plone/bumblebee_download?checksum={}&uuid={}'.format(
                     DOCX_CHECKSUM, IUUID(doc1)),
                 'target_format': 'pdf/a',
                 'url': '/plone/dossier-1/document-1/bumblebee_trigger_conversion'},
                get_queue().queue[0])
    def test_pdf_conversion_is_disabled_by_default(self):
        create(
            Builder('document').within(self.dossier).attach_file_containing(
                bumblebee_asset('example.docx').bytes(), u'example.docx'))

        get_queue().reset()

        with RequestsSessionMock.installed():
            api.content.transition(obj=self.dossier,
                                   transition='dossier-transition-resolve')
            transaction.commit()

            self.assertEquals(0, len(get_queue().queue))
Example #4
0
    def test_pdf_conversion_is_disabled_by_default(self):
        create(Builder('document')
               .within(self.dossier)
               .attach_file_containing(
                   bumblebee_asset('example.docx').bytes(),
                   u'example.docx'))

        get_queue().reset()

        with RequestsSessionMock.installed():
            api.content.transition(obj=self.dossier,
                                   transition='dossier-transition-resolve')
            transaction.commit()

            self.assertEquals(0, len(get_queue().queue))