Ignore:
Timestamp:
25 Nov 2014, 17:09:05 (10 years ago)
Author:
Henrik Bettermann
Message:

Add test for pdf file viewlets.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/fileviewlets.py

    r12057 r12058  
    313313    title = _(u'PDF File')
    314314    mus = 1024 * 200
    315     download_name = u'pdffile'
     315    download_name = u'sample.pdf'
    316316    tab_redirect = '#tab2'
    317317
     
    333333    label = _(u'PDF Scan')
    334334    title = _(u'PDF Scan')
    335     download_name = u'pdf'
     335    download_name = u'sample.pdf'
    336336
    337337
     
    339339    """Scan document.
    340340    """
    341     grok.name('pdf')
     341    grok.name('sample.pdf')
    342342    grok.context(CustomerPDFDocument)
    343343    grok.require('waeup.viewCustomer')
    344     download_name = u'pdf'
     344    download_name = u'sample.pdf'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12057 r12058  
    5050SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    5151SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp')
     52SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf')
    5253
    5354def lookup_submit_value(name, value, browser):
     
    861862            % document.document_id in logcontent)
    862863
    863     def test_edit_document(self):
     864    def test_edit_sample_document(self):
    864865        # Customers can manage documents under certain conditions
    865866        self.browser.open(self.login_path)
     
    911912        self.assertTrue('The requested form is locked' in self.browser.contents)
    912913
    913     def test_manage_upload_file(self):
     914    def test_manage_upload_sample_file(self):
    914915        # Managers can upload a file via the DocumentManageFormPage
    915916        # The image is stored even if form has errors
     
    983984            in self.browser.contents)
    984985
     986    def test_manage_upload_pdf_file(self):
     987        # Managers can upload a file via the DocumentManageFormPage
     988        # The image is stored even if form has errors
     989        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     990        self.browser.open(self.customer_path + '/documents')
     991        self.browser.getLink("Add document").click()
     992        self.browser.getControl(name="doctype").value = ['CustomerPDFDocument']
     993        self.browser.getControl("Create document").click()
     994        self.browser.open(self.documents_path + '/d102/manage')
     995        # Create a pseudo image file and select it to be uploaded
     996        image = open(SAMPLE_IMAGE, 'rb')
     997        ctrl = self.browser.getControl(name='pdfmanageupload')
     998        file_ctrl = ctrl.mech_control
     999        file_ctrl.add_file(image, filename='my_sample_scan.jpg')
     1000        self.browser.getControl(
     1001            name='upload_pdfmanageupload').click()
     1002        self.assertTrue(
     1003            'pdf file extension expected' in self.browser.contents)
     1004        ctrl = self.browser.getControl(name='pdfmanageupload')
     1005        file_ctrl = ctrl.mech_control
     1006        file_ctrl.add_file(image, filename='my_sample_scan.pdf')
     1007        self.browser.getControl(
     1008            name='upload_pdfmanageupload').click()
     1009        self.assertTrue(
     1010            'Could not determine file type' in self.browser.contents)
     1011        pdf = open(SAMPLE_PDF, 'rb')
     1012        ctrl = self.browser.getControl(name='pdfmanageupload')
     1013        file_ctrl = ctrl.mech_control
     1014        file_ctrl.add_file(pdf, filename='my_sample_scan.pdf')
     1015        self.browser.getControl(
     1016            name='upload_pdfmanageupload').click()
     1017        self.assertTrue(
     1018            'href="http://localhost/app/customers/K1000000/documents/d102/sample.pdf">PDF File</a>'
     1019            in self.browser.contents)
     1020        # Browsing the link shows a real pdf
     1021        self.browser.open('sample.pdf')
     1022        self.assertEqual(
     1023            self.browser.headers['content-type'], 'application/pdf')
    9851024
    9861025    def test_view_slips(self):
Note: See TracChangeset for help on using the changeset viewer.