Ignore:
Timestamp:
30 Aug 2014, 07:35:30 (10 years ago)
Author:
Henrik Bettermann
Message:

Add test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r11736 r11788  
    2020"""
    2121from StringIO import StringIO
     22from datetime import datetime
     23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2224from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2325from waeup.uniben.testing import FunctionalLayer
     26from waeup.uniben.configuration import CustomSessionConfiguration
    2427from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup, PH_LEN
    2528
     
    2831
    2932    layer = FunctionalLayer
     33
     34    #def setUp(self):
     35    #    super(CustomApplicantUITests, self).setUp()
     36    #    return
    3037
    3138    def test_applicant_access(self):
     
    100107            self.browser.headers['content-type'], 'image/jpeg')
    101108        self.assertEqual(len(self.browser.contents), 31)
     109
     110    def test_pay_admission_checking_fee(self):
     111        IWorkflowState(self.applicant).setState('admitted')
     112        self.applicant.screening_score = 55
     113        self.applicant.course_admitted = self.certificate
     114        self.login()
     115        # SessionConfiguration is not set, thus admission checking payment
     116        # is not necessary. Screening results and course admitted are visible.
     117        self.assertFalse(
     118            'Add admission checking payment ticket' in self.browser.contents)
     119        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
     120        self.assertTrue('55' in self.browser.contents)
     121        configuration = CustomSessionConfiguration()
     122        configuration.academic_session = datetime.now().year - 2
     123        self.app['configuration'].addSessionConfiguration(configuration)
     124        # Admission checking fee is 0, thus admission checking payment
     125        # is not necessary. Screening results and course admitted are visible.
     126        self.browser.open(self.view_path)
     127        self.assertFalse(
     128            'Add admission checking payment ticket' in self.browser.contents)
     129        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
     130        self.assertTrue('55' in self.browser.contents)
     131        configuration.admchecking_fee = 22.0
     132        # Admission checking payment button is now visible, but screening results
     133        # and course admitted are not.
     134        self.browser.open(self.view_path)
     135        self.assertTrue(
     136            'Add admission checking payment ticket' in self.browser.contents)
     137        self.assertFalse('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
     138        self.assertFalse('55' in self.browser.contents)
     139        # Application slip can't be downloaded
     140        self.assertFalse('Download application slip' in self.browser.contents)
     141        slip_path = self.view_path + '/application_slip.pdf'
     142        self.browser.open(slip_path)
     143        self.assertTrue(
     144            'Please pay admission checking fee before trying to download'
     145            in self.browser.contents)
     146        # Pay admission checking fee.
     147        self.browser.getControl("Add admission checking").click()
     148        p_id = self.applicant.keys()[0]
     149        self.applicant[p_id].p_state = 'paid'
     150        # Screening results and course admitted are visible after payment.
     151        self.browser.open(self.view_path)
     152        self.assertFalse(
     153            'Add admission checking payment ticket' in self.browser.contents)
     154        self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents)
     155        self.assertTrue('55' in self.browser.contents)
     156        # Application slip can be downloaded again.
     157        self.browser.getLink("Download application slip").click()
     158        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     159        self.assertEqual(self.browser.headers['Content-Type'],
     160                         'application/pdf')
     161        return
Note: See TracChangeset for help on using the changeset viewer.