Ignore:
Timestamp:
27 Sep 2012, 06:48:28 (12 years ago)
Author:
Henrik Bettermann
Message:

Add test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py

    r9046 r9239  
    2525from zope.interface import verify
    2626from waeup.kofa.app import University
    27 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
     27from waeup.kofa.students.tests.test_browser import (
     28    StudentsFullSetup, SAMPLE_IMAGE)
    2829from waeup.kofa.testing import FunctionalTestCase
    2930from waeup.kofa.interfaces import (
     
    249250        self.assertTrue('Clearance has been requested'
    250251            in self.browser.contents)
     252
     253    def test_manage_upload_file(self):
     254        # Managers can upload a file via the StudentClearanceManageFormPage
     255        # The image is stored even if form has errors
     256        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     257        self.browser.open(self.manage_clearance_path)
     258        # Managers can add and delete a file
     259        self.browser.open(self.manage_clearance_path)
     260        image = open(SAMPLE_IMAGE, 'rb')
     261        ctrl = self.browser.getControl(name='birthcertificateupload')
     262        file_ctrl = ctrl.mech_control
     263        file_ctrl.add_file(image, filename='my_acceptance_letter.jpg')
     264        self.browser.getControl(
     265            name='upload_acceptanceletterupload').click()
     266        # Uups, we used the wrong 'Browse' field
     267        self.assertFalse(
     268            '<a target="image" href="acc_let">'
     269            in self.browser.contents)
     270        ctrl = self.browser.getControl(name='acceptanceletterupload')
     271        file_ctrl = ctrl.mech_control
     272        image.seek(0)
     273        file_ctrl.add_file(image, filename='my_acceptance_letter.jpg')
     274        self.browser.getControl(
     275            name='upload_acceptanceletterupload').click()
     276        self.assertTrue(
     277            '<a target="image" href="acc_let">'
     278            in self.browser.contents)
     279        self.browser.getControl(
     280            name='delete_acceptanceletterupload').click()
     281        self.assertTrue(
     282            'acc_let deleted'
     283            in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.