Ignore:
Timestamp:
13 Jul 2021, 16:05:29 (3 years ago)
Author:
Henrik Bettermann
Message:

Adjust to changes in base package.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests/test_browser.py

    r16292 r16546  
    4141from kofacustom.iuokada.applicants.export import CustomApplicantExporter
    4242from kofacustom.iuokada.applicants.batching import CustomApplicantProcessor
     43
     44SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    4345
    4446class CustomApplicantUITests(ApplicantsFullSetup):
     
    159161        self.browser.open(self.transapplicant_manage_path)
    160162        # Create a pseudo file with acceptable size
    161         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
    162         pseudo_pdf = StringIO(pdf_content)
    163         ctrl = self.browser.getControl(name='res_stat.pdf')
     163        #pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
     164        #pseudo_pdf = StringIO(pdf_content)
     165        image = open(SAMPLE_IMAGE, 'rb')
     166        ctrl = self.browser.getControl(name='res_stat')
    164167        file_ctrl = ctrl.mech_control
    165         file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
     168        file_ctrl.add_file(image, filename='my_scan.jpg')
    166169        self.browser.getControl("Save").click() # submit form
    167170        # Even though the form could not be saved ...
    168171        self.assertTrue('Required input is missing' in self.browser.contents)
    169172        # ... the file has been successfully uploaded
    170         pdf_url = self.transapplicant_manage_path.replace('manage', 'res_stat.pdf')
    171         self.browser.open(pdf_url)
     173        image_url = self.transapplicant_manage_path.replace('manage', 'res_stat')
     174        self.browser.open(image_url)
    172175        self.assertEqual(
    173             self.browser.headers['content-type'], 'application/pdf')
    174         self.assertEqual(len(self.browser.contents), 307200)
     176            self.browser.headers['content-type'], 'image/jpeg')
     177        self.assertEqual(len(self.browser.contents), 2787)
    175178        # There is really a file stored for the applicant
    176179        storage = getUtility(IExtFileStore)
     
    180183        fd = storage.getFile(file_id)
    181184        file_len = len(fd.read())
    182         self.assertEqual(file_len, 307200)
     185        self.assertEqual(file_len, 2787)
    183186        # A file link is displayed on the edit view ...
    184187        self.browser.open(self.transapplicant_manage_path)
    185         self.assertTrue('<a href="res_stat.pdf">' in self.browser.contents)
     188        self.assertTrue('<a href="res_stat">' in self.browser.contents)
    186189        # ... and on the dislay view
    187190        self.browser.open(self.transapplicant_view_path)
    188         self.assertTrue('res_stat.pdf">Statement of Result</a>'
     191        self.assertTrue('res_stat">Statement of Result</a>'
    189192            in self.browser.contents)
    190193        # Adding file is properly logged
     
    194197        self.assertTrue(
    195198            'zope.mgr - kofacustom.iuokada.applicants.browser.CustomApplicantManageFormPage'
    196             ' - %s - saved: res_stat.pdf'
     199            ' - %s - saved: res_stat'
    197200            % (self.transapplicant.applicant_id)
    198201            in logcontent)
Note: See TracChangeset for help on using the changeset viewer.