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

Include permission waeup.uploadStudentFile to handle file uploads.

Fix pagetemplate filesuploadpage.pt.

Rearrange fileupload.pt

File:
1 edited

Legend:

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

    r7124 r7127  
    357357        return
    358358
    359     def test_upload_file(self):
     359    def test_manage_upload_file(self):
    360360        # Managers can upload a file via the StudentClearanceManageFormPage
    361361        # The image is stored even if form has errors
     
    372372        self.browser.open(self.edit_clearance_student_path)
    373373        pseudo_image = StringIO('I pretend to be a graphics file')
    374         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     374        ctrl = self.browser.getControl(name='birthcertificateupload')
    375375        file_ctrl = ctrl.mech_control
    376376        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
     
    382382        # ... but the correct upload submit button does
    383383        pseudo_image = StringIO('I pretend to be a graphics file')
    384         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     384        ctrl = self.browser.getControl(name='birthcertificateupload')
    385385        file_ctrl = ctrl.mech_control
    386386        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
    387387        self.browser.getControl(
    388             name='upload_birthcertificateuploadmanage').click()
     388            name='upload_birthcertificateupload').click()
    389389        # There is a correct <img> link included
    390390        self.assertTrue(
     
    401401        photo_content = 'A' * 1024 * 151  # A string of 21 KB size
    402402        pseudo_image = StringIO(photo_content)
    403         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     403        ctrl = self.browser.getControl(name='birthcertificateupload')
    404404        file_ctrl = ctrl.mech_control
    405405        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.jpg')
    406406        self.browser.getControl(
    407             name='upload_birthcertificateuploadmanage').click()
     407            name='upload_birthcertificateupload').click()
    408408        self.assertTrue(
    409409            'Uploaded file is too big' in self.browser.contents)
    410410        # File names must meet several conditions
    411411        pseudo_image = StringIO('I pretend to be a graphics file')
    412         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     412        ctrl = self.browser.getControl(name='birthcertificateupload')
    413413        file_ctrl = ctrl.mech_control
    414414        file_ctrl.add_file(pseudo_image, filename='my.photo.jpg')
    415415        self.browser.getControl(
    416             name='upload_birthcertificateuploadmanage').click()
     416            name='upload_birthcertificateupload').click()
    417417        self.assertTrue('File name contains more than one dot'
    418418            in self.browser.contents)
    419         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     419        ctrl = self.browser.getControl(name='birthcertificateupload')
    420420        file_ctrl = ctrl.mech_control
    421421        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate')
    422422        self.browser.getControl(
    423             name='upload_birthcertificateuploadmanage').click()
     423            name='upload_birthcertificateupload').click()
    424424        self.assertTrue('File name has no extension' in self.browser.contents)
    425         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     425        ctrl = self.browser.getControl(name='birthcertificateupload')
    426426        file_ctrl = ctrl.mech_control
    427427        file_ctrl.add_file(pseudo_image, filename='my_birth_certificate.bmp')
    428428        self.browser.getControl(
    429             name='upload_birthcertificateuploadmanage').click()
     429            name='upload_birthcertificateupload').click()
    430430        self.assertTrue('Only the following extension are allowed'
    431431            in self.browser.contents)
    432432        # Managers can delete files
    433         self.browser.getControl(name='delete_birthcertificateuploadmanage').click()
     433        self.browser.getControl(name='delete_birthcertificateupload').click()
    434434        self.assertTrue(
    435435            'birth_certificate deleted' in self.browser.contents)
     
    437437        self.browser.open(self.edit_clearance_student_path)
    438438        pseudo_image = StringIO('I pretend to be a graphics file')
    439         ctrl = self.browser.getControl(name='birthcertificateuploadmanage')
     439        ctrl = self.browser.getControl(name='birthcertificateupload')
    440440        file_ctrl = ctrl.mech_control
    441441        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
    442442        self.browser.getControl(
    443             name='upload_acceptanceletteruploadmanage').click()
     443            name='upload_acceptanceletterupload').click()
    444444        self.assertFalse(
    445445            '<a target="image" href="acceptance_letter">'
    446446            in self.browser.contents)
    447         ctrl = self.browser.getControl(name='acceptanceletteruploadmanage')
     447        ctrl = self.browser.getControl(name='acceptanceletterupload')
    448448        file_ctrl = ctrl.mech_control
    449449        file_ctrl.add_file(pseudo_image, filename='my_acceptance_letter.jpg')
    450450        self.browser.getControl(
    451             name='upload_acceptanceletteruploadmanage').click()
     451            name='upload_acceptanceletterupload').click()
    452452        self.assertTrue(
    453453            '<a target="image" href="acceptance_letter">'
    454454            in self.browser.contents)
    455455        self.browser.getControl(
    456             name='delete_acceptanceletteruploadmanage').click()
     456            name='delete_acceptanceletterupload').click()
    457457        self.assertTrue(
    458458            'acceptance_letter deleted'
     
    738738        self.browser.getControl(name="form.password").value = 'spwd'
    739739        self.browser.getControl("Login").click()
     740        # Student can upload a passport picture
     741        self.browser.open(self.student_path + '/change_portrait')
     742        pseudo_image = StringIO('I pretend to be a graphics file')
     743        ctrl = self.browser.getControl(name='passportuploadedit')
     744        file_ctrl = ctrl.mech_control
     745        file_ctrl.add_file(pseudo_image, filename='my_photo.jpg')
     746        self.browser.getControl(
     747            name='upload_passportuploadedit').click()
     748        self.assertTrue(
     749            '<img align="middle" height="125px" src="passport.jpg" />'
     750            in self.browser.contents)
    740751        # Student can view the clearance data
    741752        self.browser.getLink("Clearance Data").click()
Note: See TracChangeset for help on using the changeset viewer.