Ignore:
Timestamp:
25 Jun 2013, 12:46:38 (12 years ago)
Author:
Henrik Bettermann
Message:

Change notice and remove upload fields.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.imostate/trunk/src/waeup/imostate/applicants/tests/test_browser.py

    r10366 r10382  
    161161        self.assertTrue(fd is None)
    162162
    163     def test_upload_refereeform_by_student(self):
    164         self.login()
    165         self.browser.open(self.edit_path)
    166         # Create a pseudo file and select it to be uploaded in form
    167         pdf_content = 'A' * 1024 * 600  # A string of 600 KB size
    168         pseudo_file = StringIO(pdf_content)
    169         ctrl = self.browser.getControl(name='form.refereeform')
    170         file_ctrl = ctrl.mech_control
    171         file_ctrl.add_file(pseudo_file, filename='myform.pdf')
    172         self.browser.getControl("Save").click() # submit form
    173         # We get a warning message
    174         self.assertTrue(
    175             'Uploaded file is too big' in self.browser.contents)
    176         # Create a pseudo file with acceptable size
    177         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
    178         pseudo_file = StringIO(pdf_content)
    179         ctrl = self.browser.getControl(name='form.refereeform')
    180         file_ctrl = ctrl.mech_control
    181         file_ctrl.add_file(pseudo_file, filename='myform.pdf')
    182         self.browser.getControl("Save").click() # submit form
    183         # Even though the form could not be saved ...
    184         self.assertTrue('Required input is missing' in self.browser.contents)
    185         # ... the file has been successfully uploaded
    186         pdf_url = self.edit_path.replace('edit', 'refereeform.pdf')
    187         self.browser.open(pdf_url)
    188         self.assertEqual(
    189             self.browser.headers['content-type'], 'application/pdf')
    190         self.assertEqual(len(self.browser.contents), 307200)
    191         # There is really a file stored for the applicant
    192         storage = getUtility(IExtFileStore)
    193         file_id = IFileStoreNameChooser(self.applicant).chooseName(
    194             attr='refereeform.pdf')
    195         # The stored file can be fetched
    196         fd = storage.getFile(file_id)
    197         file_len = len(fd.read())
    198         self.assertEqual(file_len, 307200)
    199         # A file link is displayed on the edit view ...
    200         self.browser.open(self.edit_path)
    201         self.assertTrue('<a href="refereeform.pdf">' in self.browser.contents)
    202         # ... and on the dislay view
    203         self.browser.open(self.view_path)
    204         self.assertTrue('<a href="refereeform.pdf">Referee\'s Form</a>'
    205             in self.browser.contents)
    206 
    207     def test_upload_refereeform_by_manager(self):
    208         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    209         self.browser.open(self.manage_path)
    210         # Create a pseudo file with acceptable size
    211         pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
    212         pseudo_file = StringIO(pdf_content)
    213         ctrl = self.browser.getControl(name='form.refereeform')
    214         file_ctrl = ctrl.mech_control
    215         file_ctrl.add_file(pseudo_file, filename='myform.pdf')
    216         self.browser.getControl("Save").click() # submit form
    217         # Even though the form could not be saved ...
    218         self.assertTrue('Required input is missing' in self.browser.contents)
    219         # ... the file has been successfully uploaded
    220         pdf_url = self.manage_path.replace('manage', 'refereeform.pdf')
    221         self.browser.open(pdf_url)
    222         self.assertEqual(
    223             self.browser.headers['content-type'], 'application/pdf')
    224         self.assertEqual(len(self.browser.contents), 307200)
    225         # There is rally a file stored for the applicant
    226         storage = getUtility(IExtFileStore)
    227         file_id = IFileStoreNameChooser(self.applicant).chooseName(
    228             attr='refereeform.pdf')
    229         # The stored file can be fetched
    230         fd = storage.getFile(file_id)
    231         file_len = len(fd.read())
    232         self.assertEqual(file_len, 307200)
    233         # A file link is displayed on the edit view ...
    234         self.browser.open(self.manage_path)
    235         self.assertTrue('<a href="refereeform.pdf">' in self.browser.contents)
    236         # ... and on the dislay view
    237         self.browser.open(self.view_path)
    238         self.assertTrue('<a href="refereeform.pdf">Referee\'s Form</a>'
    239             in self.browser.contents)
    240         # Adding file is properly logged
    241         logfile = os.path.join(
    242             self.app['datacenter'].storage, 'logs', 'applicants.log')
    243         logcontent = open(logfile).read()
    244         self.assertTrue(
    245             'zope.mgr - waeup.imostate.applicants.browser.CustomApplicantManageFormPage'
    246             ' - %s - saved: refereeform'
    247             % (self.applicant.applicant_id)
    248             in logcontent)
    249         # When an applicant is removed, also the pdf files are gone.
    250         del self.app['applicants']['app2011'][self.applicant.application_number]
    251         fd = storage.getFile(file_id)
    252         self.assertTrue(fd is None)
    253 
    254163    def test_applicant_workflow(self):
    255164        # Applicants can edit their record
     
    275184        file_ctrl = ctrl.mech_control
    276185        file_ctrl.add_file(pseudo_file, filename='myform.pdf')
    277         ctrl = self.browser.getControl(name='form.refereeform')
    278         file_ctrl = ctrl.mech_control
    279         file_ctrl.add_file(pseudo_file, filename='myform.pdf')
    280186
    281187        self.browser.getControl(name="confirm_passport").value = True
Note: See TracChangeset for help on using the changeset viewer.