Index: /main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py	(revision 11787)
+++ /main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py	(revision 11788)
@@ -20,6 +20,9 @@
 """
 from StringIO import StringIO
+from datetime import datetime
+from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
 from zope.securitypolicy.interfaces import IPrincipalRoleManager
 from waeup.uniben.testing import FunctionalLayer
+from waeup.uniben.configuration import CustomSessionConfiguration
 from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup, PH_LEN
 
@@ -28,4 +31,8 @@
 
     layer = FunctionalLayer
+
+    #def setUp(self):
+    #    super(CustomApplicantUITests, self).setUp()
+    #    return
 
     def test_applicant_access(self):
@@ -100,2 +107,55 @@
             self.browser.headers['content-type'], 'image/jpeg')
         self.assertEqual(len(self.browser.contents), 31)
+
+    def test_pay_admission_checking_fee(self):
+        IWorkflowState(self.applicant).setState('admitted')
+        self.applicant.screening_score = 55
+        self.applicant.course_admitted = self.certificate
+        self.login()
+        # SessionConfiguration is not set, thus admission checking payment
+        # is not necessary. Screening results and course admitted are visible.
+        self.assertFalse(
+            'Add admission checking payment ticket' in self.browser.contents)
+        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
+        self.assertTrue('55' in self.browser.contents)
+        configuration = CustomSessionConfiguration()
+        configuration.academic_session = datetime.now().year - 2
+        self.app['configuration'].addSessionConfiguration(configuration)
+        # Admission checking fee is 0, thus admission checking payment
+        # is not necessary. Screening results and course admitted are visible.
+        self.browser.open(self.view_path)
+        self.assertFalse(
+            'Add admission checking payment ticket' in self.browser.contents)
+        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
+        self.assertTrue('55' in self.browser.contents)
+        configuration.admchecking_fee = 22.0
+        # Admission checking payment button is now visible, but screening results
+        # and course admitted are not.
+        self.browser.open(self.view_path)
+        self.assertTrue(
+            'Add admission checking payment ticket' in self.browser.contents)
+        self.assertFalse('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
+        self.assertFalse('55' in self.browser.contents)
+        # Application slip can't be downloaded
+        self.assertFalse('Download application slip' in self.browser.contents)
+        slip_path = self.view_path + '/application_slip.pdf'
+        self.browser.open(slip_path)
+        self.assertTrue(
+            'Please pay admission checking fee before trying to download'
+            in self.browser.contents)
+        # Pay admission checking fee.
+        self.browser.getControl("Add admission checking").click()
+        p_id = self.applicant.keys()[0]
+        self.applicant[p_id].p_state = 'paid'
+        # Screening results and course admitted are visible after payment.
+        self.browser.open(self.view_path)
+        self.assertFalse(
+            'Add admission checking payment ticket' in self.browser.contents)
+        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
+        self.assertTrue('55' in self.browser.contents)
+        # Application slip can be downloaded again.
+        self.browser.getLink("Download application slip").click()
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.headers['Content-Type'],
+                         'application/pdf')
+        return
