Ejemplo n.º 1
0
 def test_erp5_merge_pdf(self):
     document = self.portal.portal_contributions.newContent(
         file=makeFileUpload('REF-en-001.pdf'))
     merged_pdf_data = self.portal.ERP5Site_mergePDFList(
         [document.getData(), document.getData()])
     merged_document = self.portal.document_module.newContent(
         portal_type='PDF', data=merged_pdf_data)
     self.assertEqual('2', merged_document.getContentInformation()['Pages'])
Ejemplo n.º 2
0
 def test_erp5_merge_pdf(self):
   document = self.portal.portal_contributions.newContent(
     file=makeFileUpload('REF-en-001.pdf'))
   merged_pdf_data = self.portal.ERP5Site_mergePDFList(
     [document.getData(), document.getData()])
   merged_document = self.portal.document_module.newContent(
     portal_type='PDF',
     data=merged_pdf_data)
   self.assertEqual('2', merged_document.getContentInformation()['Pages'])
Ejemplo n.º 3
0
 def test_erp5_merge_pdf_start_on_recto(self):
     document = self.portal.portal_contributions.newContent(
         file=makeFileUpload('REF-en-001.pdf'))
     merged_pdf_data = self.portal.ERP5Site_mergePDFList(
         [document.getData(), document.getData()], start_on_recto=True)
     merged_document = self.portal.document_module.newContent(
         portal_type='PDF', data=merged_pdf_data)
     # there are four pages, because blank pages has been added so that the
     # second time, our document starts on a recto page.
     self.assertEqual('4', merged_document.getContentInformation()['Pages'])
Ejemplo n.º 4
0
 def test_erp5_merge_pdf_start_on_recto(self):
   document = self.portal.portal_contributions.newContent(
     file=makeFileUpload('REF-en-001.pdf'))
   merged_pdf_data = self.portal.ERP5Site_mergePDFList(
     [document.getData(), document.getData()], start_on_recto=True)
   merged_document = self.portal.document_module.newContent(
     portal_type='PDF',
     data=merged_pdf_data)
   # there are four pages, because blank pages has been added so that the
   # second time, our document starts on a recto page.
   self.assertEqual('4', merged_document.getContentInformation()['Pages'])
    def test_01_no_retry_for_no_network_issue(self):
        system_pref = self.getDefaultSystemPreference()
        system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
        self.tic()

        filename = 'monochrome_sample.tiff'
        file = makeFileUpload(filename)
        document = self.portal.document_module.newContent(portal_type='Text')
        document.edit(file=file)
        message = document.Document_tryToConvertToBaseFormat()
        self.assertEqual(
            message.count('Error converting document to base format'), 1)
Ejemplo n.º 6
0
    def test_03_createDiscussionThread(self):
        """
      Create a disucssion thread
    """
        portal = self.portal

        # create web sections & set predicates
        group1 = portal.portal_categories.group.newContent(
            portal_type='Category', title='Group 1')
        web_site = portal.web_site_module.newContent(portal_type='Web Site')
        web_section1 = web_site.newContent(portal_type='Web Section')
        web_section1.setMultimembershipCriterionBaseCategoryList(['group'])
        web_section1.setMembershipCriterionCategoryList(
            [group1.getRelativeUrl()])
        self.tic()

        web_section1.WebSection_createNewDiscussionThread(
            'test1-new', 'test1 body')
        discussion_thread = [x for x in self.portal.discussion_thread_module.objectValues() \
                              if x.getReference()=='test1-new'][0]
        # not indexed yet
        self.assertSameSet([],
                           web_section1.WebSection_getDiscussionThreadList())

        # not indexed but its relative url is passed through REQUEST
        self.app.REQUEST.set('thread_relative_url',
                             discussion_thread.getRelativeUrl())
        self.assertSameSet([discussion_thread],
                           web_section1.WebSection_getDiscussionThreadList())

        self.tic()
        # indexed already
        self.assertSameSet([discussion_thread],
                           web_section1.WebSection_getDiscussionThreadList())
        discussion_post = discussion_thread.contentValues(
            filter={'portal_type': 'Discussion Post'})[0]
        attachment_list = discussion_post.DiscussionPost_getAttachmentList()
        self.assertEqual(discussion_thread.getValidationState(), 'published')
        self.assertEqual(0, len(attachment_list))

        # check attachment creation
        file = makeFileUpload('TEST-en-002.doc')
        web_section1.WebSection_createNewDiscussionThread(
            'test1-new-with-attachment', 'test1 body', file=file)
        discussion_thread = [x for x in self.portal.discussion_thread_module.objectValues() \
                              if x.getReference()=='test1-new-with-attachment'][0]
        self.tic()

        discussion_post = discussion_thread.contentValues(
            filter={'portal_type': 'Discussion Post'})[0]
        attachment_list = discussion_post.DiscussionPost_getAttachmentList()
        self.assertEqual(discussion_thread.getValidationState(), 'published')
        self.assertEqual(1, len(attachment_list))
    def test_03_retry_for_socket_issue(self):
        system_pref = self.getDefaultSystemPreference()
        server_list = system_pref.getPreferredDocumentConversionServerUrlList()
        system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
        system_pref.setPreferredOoodocServerTimeout(1)
        self.tic()
        filename = 'TEST-en-002.doc'
        file = makeFileUpload(filename)
        document = self.portal.portal_contributions.newContent(file=file)

        message = document.Document_tryToConvertToBaseFormat()
        if 'Socket Error: SSLError' in message:
            self.assertEqual(message.count('Socket Error: SSLError'),
                             (self.retry_count + 1) * len(server_list))
Ejemplo n.º 8
0
  def test_03_createDiscussionThread(self):
    """
      Create a disucssion thread
    """
    portal = self.portal
    discussion_thread_id_set = set(portal.discussion_thread_module.objectIds())

    # create web sections & set predicates
    group1 = portal.portal_categories.group.newContent(portal_type='Category',
                                                       title = 'Group 1')
    web_site = portal.web_site_module.newContent(portal_type='Web Site')
    web_section1 = web_site.newContent(portal_type='Web Section')
    web_section1.setMultimembershipCriterionBaseCategoryList(['group'])
    web_section1.setMembershipCriterionCategoryList([group1.getRelativeUrl()])
    self.tic()

    web_section1.WebSection_createNewDiscussionThread('test1-new', 'test1 body')
    discussion_thread, = [x for x in self.portal.discussion_thread_module.objectValues() \
                          if x.getId() not in discussion_thread_id_set]
    discussion_thread_id_set.add(discussion_thread.getId())
    self.assertTrue(discussion_thread.getReference().startswith("test1-new-"))
    # not indexed yet
    self.assertSameSet([], web_section1.WebSection_getDiscussionThreadList())

    # not indexed but its relative url is passed through REQUEST
    self.app.REQUEST.set('thread_relative_url', discussion_thread.getRelativeUrl())
    self.assertSameSet([discussion_thread], web_section1.WebSection_getDiscussionThreadList())

    self.tic()
    # indexed already
    self.assertSameSet([discussion_thread], web_section1.WebSection_getDiscussionThreadList())
    discussion_post = discussion_thread.contentValues(filter={'portal_type': 'Discussion Post'})[0]
    attachment_list = discussion_post.DiscussionPost_getAttachmentList()
    self.assertEqual(discussion_thread.getValidationState(), 'published')
    self.assertEqual(0, len(attachment_list))

    # check attachment creation
    file = makeFileUpload('TEST-en-002.doc')
    web_section1.WebSection_createNewDiscussionThread('test1-new-with-attachment', 'test1 body', file=file)
    discussion_thread, = [x for x in self.portal.discussion_thread_module.objectValues() \
                          if x.getId() not in discussion_thread_id_set]
    discussion_thread_id_set.add(discussion_thread.getId())
    self.assertTrue(discussion_thread.getReference().startswith("test1-new-with-attachment-"))
    self.tic()

    discussion_post = discussion_thread.contentValues(filter={'portal_type': 'Discussion Post'})[0]
    attachment_list = discussion_post.DiscussionPost_getAttachmentList()
    self.assertEqual(discussion_thread.getValidationState(), 'published')
    self.assertEqual(1, len(attachment_list))
Ejemplo n.º 9
0
    def test_Zuite_uploadScreenShot(self):
        """
      Test Screeshot upload script used by Zelenium to
      update screenshots of the documents.
    """
        image_upload = makeFileUpload('TEST-en-002.png')
        self.assertNotEquals(None, image_upload)

        # Create a web page, and check if the content is not overwriten
        web_page_reference = "WEB-PAGE-REFERENCE"
        web_page = self.portal.web_page_module.newContent(
            reference=web_page_reference, language="en", version="001")
        web_page.publishAlive()
        self.tic()

        image_reference = "IMAGE-REFERENCE-%s" % str(time())
        image_page = self.portal.image_module.newContent(
            reference=image_reference, language="en", version="001")
        image_page.publishAlive()
        self.tic()
        image_page_2 = self.portal.image_module.newContent(
            reference=image_reference, language="en", version="002")
        image_page_2.publishAlive()
        self.tic()

        self.portal.REQUEST.form['data_uri'] = image_upload
        fake_image_reference = "DO-NOT-EXISTANT-IMAGE"
        self.assertNotEquals(
            None,
            self.portal.Zuite_uploadScreenshot(image_upload,
                                               fake_image_reference))

        self.assertNotEquals(
            None,
            self.portal.Zuite_uploadScreenshot(image_upload,
                                               web_page_reference))

        self.assertEqual(
            None,
            self.portal.Zuite_uploadScreenshot(image_upload, image_reference))

        self.tic()
        # The right image were updated.
        image_upload.seek(0)
        self.assertEqual(image_page_2.getData(),
                         image_upload.read().decode("base64"))
        self.assertEqual(image_page_2.getFilename(), image_reference + '.png')
        self.assertEqual(image_page.getData(), '')
Ejemplo n.º 10
0
  def test_Zuite_uploadScreenShot(self):
    """
      Test Screeshot upload script used by Zelenium to 
      update screenshots of the documents.
    """
    image_upload = makeFileUpload('TEST-en-002.png')
    self.assertNotEquals(None, image_upload)
    
    # Create a web page, and check if the content is not overwriten
    web_page_reference = "WEB-PAGE-REFERENCE"
    web_page = self.portal.web_page_module.newContent(
                                     reference=web_page_reference, 
                                     language="en", version="001")
    web_page.publishAlive()
    self.tic()

    image_reference = "IMAGE-REFERENCE-%s" % str(time())
    image_page = self.portal.image_module.newContent(
                                   reference=image_reference, 
                                   language="en", version="001")
    image_page.publishAlive()
    self.tic()
    image_page_2 = self.portal.image_module.newContent(
                                   reference=image_reference, 
                                   language="en", version="002")
    image_page_2.publishAlive()
    self.tic()

    self.portal.REQUEST.form['data_uri'] = image_upload
    fake_image_reference = "DO-NOT-EXISTANT-IMAGE"
    self.assertNotEquals(None, 
                   self.portal.Zuite_uploadScreenshot(image_upload, fake_image_reference))

    self.assertNotEquals(None, 
                   self.portal.Zuite_uploadScreenshot(image_upload, web_page_reference))

    self.assertEqual(None, 
                   self.portal.Zuite_uploadScreenshot(image_upload, image_reference))

    self.tic()
    # The right image were updated.
    image_upload.seek(0)
    self.assertEqual(image_page_2.getData(), image_upload.read().decode("base64"))
    self.assertEqual(image_page_2.getFilename(), image_reference + '.png')
    self.assertEqual(image_page.getData(), '')
    def test_02_retry_for_network_issue(self):
        system_pref = self.getDefaultSystemPreference()
        saved_server_list = system_pref.getPreferredDocumentConversionServerUrlList(
        )
        system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
        system_pref.setPreferredDocumentConversionServerUrlList(
            ['https://broken.url'])
        self.tic()
        filename = 'TEST-en-002.doc'
        file = makeFileUpload(filename)
        document = self.portal.portal_contributions.newContent(file=file)

        message = document.Document_tryToConvertToBaseFormat()
        self.assertEqual(message.count('broken.url: Connection refused'),
                         self.retry_count + 1)
        system_pref.setPreferredDocumentConversionServerUrlList(
            saved_server_list)
        self.commit()