Ignore:
Timestamp:
14 Nov 2011, 12:17:54 (13 years ago)
Author:
Henrik Bettermann
Message:

Add second file upload viewlet, add tests and repair FileUpload? methods. Each button must get a dedicated id and name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7110 r7111  
    374374        ctrl = self.browser.getControl(name='birth_certificate')
    375375        file_ctrl = ctrl.mech_control
    376         file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
     376        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
    377377        # The Save action does not upload files
    378378        self.browser.getControl("Save (no upload)").click() # submit form
     
    380380            '<a target="image" href="birth_certificate.jpg">'
    381381            in self.browser.contents)
    382         # ... but the Upload submit button does
     382        # ... but the correct upload submit button does
    383383        pseudo_image = StringIO('I pretend to be a graphics file')
    384384        ctrl = self.browser.getControl(name='birth_certificate')
    385385        file_ctrl = ctrl.mech_control
    386         file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
    387         self.browser.getControl("Upload").click()
     386        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
     387        self.browser.getControl(name='upload_birth_certificate').click()
    388388        # There is a correct <img> link included
    389389        self.assertTrue(
     
    401401        ctrl = self.browser.getControl(name='birth_certificate')
    402402        file_ctrl = ctrl.mech_control
    403         file_ctrl.add_file(pseudo_image, filename='myphoto.jpg')
    404         self.browser.getControl("Upload").click()
     403        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
     404        self.browser.getControl(name='upload_birth_certificate').click()
    405405        self.assertTrue(
    406406            'Uploaded file is too big' in self.browser.contents)
     
    410410        file_ctrl = ctrl.mech_control
    411411        file_ctrl.add_file(pseudo_image, filename='my.photo.jpg')
    412         self.browser.getControl("Upload").click()
     412        self.browser.getControl(name='upload_birth_certificate').click()
    413413        self.assertTrue('File name contains more than one dot'
    414414            in self.browser.contents)
    415415        ctrl = self.browser.getControl(name='birth_certificate')
    416416        file_ctrl = ctrl.mech_control
    417         file_ctrl.add_file(pseudo_image, filename='myphoto')
    418         self.browser.getControl("Upload").click()
     417        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate')
     418        self.browser.getControl(name='upload_birth_certificate').click()
    419419        self.assertTrue('File name has no extension' in self.browser.contents)
    420420        ctrl = self.browser.getControl(name='birth_certificate')
    421421        file_ctrl = ctrl.mech_control
    422         file_ctrl.add_file(pseudo_image, filename='myphoto.bmp')
    423         self.browser.getControl("Upload").click()
     422        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.bmp')
     423        self.browser.getControl(name='upload_birth_certificate').click()
    424424        self.assertTrue('.jpg file extension expected' in self.browser.contents)
    425425        # Managers can delete files
    426         self.browser.getControl("Delete").click()
     426        self.browser.getControl(name='delete_birth_certificate').click()
    427427        self.assertTrue(
    428428            'File birth_certificate.jpg deleted'
     429            in self.browser.contents)
     430        # Managers can add and delete second file
     431        self.browser.open(self.edit_clearance_student_path)
     432        pseudo_image = StringIO('I pretend to be a graphics file')
     433        ctrl = self.browser.getControl(name='birth_certificate')
     434        file_ctrl = ctrl.mech_control
     435        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
     436        self.browser.getControl(name='upload_acceptance_letter').click()
     437        self.assertFalse(
     438            '<a target="image" href="acceptance_letter.jpg">'
     439            in self.browser.contents)
     440        ctrl = self.browser.getControl(name='acceptance_letter')
     441        file_ctrl = ctrl.mech_control
     442        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
     443        self.browser.getControl(name='upload_acceptance_letter').click()
     444        self.assertTrue(
     445            '<a target="image" href="acceptance_letter.jpg">'
     446            in self.browser.contents)
     447        self.browser.getControl(name='delete_acceptance_letter').click()
     448        self.assertTrue(
     449            'File acceptance_letter.jpg deleted'
    429450            in self.browser.contents)
    430451
Note: See TracChangeset for help on using the changeset viewer.