Index: main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py	(revision 15462)
+++ main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py	(revision 15530)
@@ -381,2 +381,74 @@
         fd = storage.getFile(file_id)
         self.assertTrue(fd is None)
+
+    def test_upload_verificationdoc_by_manager(self):
+        # Add ver applicants container
+        self.vercontainer = ApplicantsContainer()
+        self.vercontainer.mode = 'create'
+        self.vercontainer.code = u'ver%s' % session_1
+        self.vercontainer.prefix = u'ver'
+        self.vercontainer.application_category = u'no'
+        self.vercontainer.year = session_1
+        self.vercontainer.application_fee = 300.0
+        self.vercontainer.title = u'This is the ver%s container' % session_1
+        self.app['applicants'][self.vercontainer.code] = self.vercontainer
+        delta = datetime.timedelta(days=10)
+        self.vercontainer.startdate = datetime.datetime.now(pytz.utc) - delta
+        self.vercontainer.enddate = datetime.datetime.now(pytz.utc) + delta
+        # Add applicant
+        verapplicant = createObject(u'waeup.Applicant')
+        verapplicant.firstname = u'Anna'
+        verapplicant.lastname = u'Post'
+        self.app['applicants'][self.vercontainer.code].addApplicant(verapplicant)
+        self.verapplicant = self.app['applicants'][self.vercontainer.code][
+            verapplicant.application_number]
+        self.verapplicant_view_path = ('http://localhost/app/applicants/ver%s/%s'
+            % (session_1, verapplicant.application_number))
+        self.verapplicant_manage_path = ('http://localhost/app/applicants/ver%s/%s/manage'
+            % (session_1, verapplicant.application_number))
+        # Login
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.verapplicant_manage_path)
+        # Create a pseudo file with acceptable size
+        pdf_content = 'A' * 1024 * 300  # A string of 300 KB size
+        pseudo_pdf = StringIO(pdf_content)
+        ctrl = self.browser.getControl(name='form.verificationdoc')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(pseudo_pdf, filename='myform.pdf')
+        self.browser.getControl("Save").click() # submit form
+        # Even though the form could not be saved ...
+        self.assertTrue('Required input is missing' in self.browser.contents)
+        # ... the file has been successfully uploaded
+        pdf_url = self.verapplicant_manage_path.replace('manage', 'verificationdoc.pdf')
+        self.browser.open(pdf_url)
+        self.assertEqual(
+            self.browser.headers['content-type'], 'application/pdf')
+        self.assertEqual(len(self.browser.contents), 307200)
+        # There is really a file stored for the applicant
+        storage = getUtility(IExtFileStore)
+        file_id = IFileStoreNameChooser(self.verapplicant).chooseName(
+            attr='verificationdoc.pdf')
+        # The stored file can be fetched
+        fd = storage.getFile(file_id)
+        file_len = len(fd.read())
+        self.assertEqual(file_len, 307200)
+        # A file link is displayed on the edit view ...
+        self.browser.open(self.verapplicant_manage_path)
+        self.assertTrue('<a href="verificationdoc.pdf">' in self.browser.contents)
+        # ... and on the dislay view
+        self.browser.open(self.verapplicant_view_path)
+        self.assertTrue('<a href="verificationdoc.pdf">Result/Certificate Document</a>'
+            in self.browser.contents)
+        # Adding file is properly logged
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'applicants.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'zope.mgr - waeup.aaue.applicants.browser.CustomApplicantManageFormPage'
+            ' - %s - saved: verificationdoc'
+            % (self.verapplicant.applicant_id)
+            in logcontent)
+        # When an applicant is removed, also the pdf files are gone.
+        del self.app['applicants'][self.vercontainer.code][self.verapplicant.application_number]
+        fd = storage.getFile(file_id)
+        self.assertTrue(fd is None)
