Changeset 6942


Ignore:
Timestamp:
25 Oct 2011, 09:44:52 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganize test_manage_payments and add more tests for payments made by students.

File:
1 edited

Legend:

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

    r6941 r6942  
    659659        self.app['configuration'].addSessionConfiguration(configuration)
    660660
    661         # Managers can add and remove online school fee payment tickets
     661        # Managers can add online school fee payment tickets
    662662        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    663663        self.browser.open(self.payments_student_path)
    664         #self.browser.getLink("Manage").click()
    665664        self.browser.getControl("Add online payment ticket").click()
    666665        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     
    673672        self.assertMatches('...Amount Authorized...',
    674673                           self.browser.contents)
     674
     675        # Managers can open the callback view which simulates a valid callback
     676        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
     677        self.browser.open(self.browser.url + '/callback')
     678        self.assertMatches('...Valid callback received...',
     679                          self.browser.contents)
     680
     681        # Managers can remove online school fee payment tickets
    675682        self.browser.open(self.payments_student_path)
    676         #self.browser.getLink('Manage').click()
    677683        self.browser.getControl("Remove selected").click()
    678684        self.assertMatches('...No payment selected...', self.browser.contents)
     
    719725                           self.browser.contents)
    720726
    721         # Managers can add online schoolfee payment tickets
     727
     728
     729    def test_student_payments(self):
     730        # Set up SessionConfiguration object
     731        configuration = SessionConfiguration()
     732        configuration.academic_session = 2004
     733        configuration.fee_1 = 20000
     734        self.app['configuration'].addSessionConfiguration(configuration)
     735        self.browser.open(self.login_path)
     736        self.browser.getControl(name="form.login").value = self.student_id
     737        self.browser.getControl(name="form.password").value = 'spwd'
     738        self.browser.getControl("Login").click()
     739
     740        # Students can add online clearance payment tickets
    722741        self.browser.open(self.payments_student_path + '/addop')
    723         self.browser.getControl(name="form.p_category").value = ['schoolfee']
     742        self.browser.getControl(name="form.p_category").value = ['clearance']
    724743        self.browser.getControl("Create ticket").click()
    725744        self.assertMatches('...ticket created...',
    726745                           self.browser.contents)
    727746
    728         # Managers can open the callback view which simulates a valid callback
    729         self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
     747        # Students can open the callback view which simulates a valid callback
     748        self.assertEqual(len(self.app['accesscodes']['CLR-0']),0)
    730749        ctrl = self.browser.getControl(name='val_id')
    731750        value = ctrl.options[0]
     
    734753        self.assertMatches('...Valid callback received...',
    735754                          self.browser.contents)
     755        expected = '''...
     756        <td>
     757          Paid
     758        </td>...'''
     759        self.assertMatches(expected,self.browser.contents)
     760        # The new CLR-0 pin has been created
     761        self.assertEqual(len(self.app['accesscodes']['CLR-0']),1)
     762        pin = self.app['accesscodes']['CLR-0'].keys()[0]
     763        ac = self.app['accesscodes']['CLR-0'][pin]
     764        ac.owner = self.student_id
     765        # The new CLR-0 pin can be used for starting clearance
     766        IWorkflowInfo(self.student).fireTransition('admit')
     767        self.browser.open(self.student_path + '/start_clearance')
     768        parts = pin.split('-')[1:]
     769        clrseries, clrnumber = parts
     770        self.browser.getControl(name="ac_series").value = clrseries
     771        self.browser.getControl(name="ac_number").value = clrnumber
     772        self.browser.getControl("Start clearance now").click()
     773        self.assertMatches('...Clearance process has been started...',
     774                           self.browser.contents)
     775
     776        # Students can add online school fee payment tickets
     777        self.browser.open(self.payments_student_path)
     778        self.browser.getControl("Add online payment ticket").click()
     779        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     780        self.browser.getControl("Create ticket").click()
     781        self.assertMatches('...ticket created...',
     782                           self.browser.contents)
     783        ctrl = self.browser.getControl(name='val_id')
     784        value = ctrl.options[0]
     785        self.browser.getLink(value).click()
     786        self.assertMatches('...Amount Authorized...',
     787                           self.browser.contents)
     788
     789        # Students can open the callback view which simulates a valid callback
     790        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
     791        self.browser.open(self.browser.url + '/callback')
     792        self.assertMatches('...Valid callback received...',
     793                          self.browser.contents)
     794
     795        # Students can remove only online payment tickets which have
     796        # not received a valid callback
     797        self.browser.open(self.payments_student_path)
     798        self.assertRaises(
     799            LookupError, self.browser.getControl, name='val_id')
     800        self.browser.open(self.payments_student_path + '/addop')
     801        self.browser.getControl(name="form.p_category").value = ['gown']
     802        self.browser.getControl("Create ticket").click()
     803        self.browser.open(self.payments_student_path)
     804        ctrl = self.browser.getControl(name='val_id')
     805        value = ctrl.options[0]
     806        ctrl.getControl(value=value).selected = True
     807        self.browser.getControl("Remove selected", index=0).click()
     808        self.assertTrue('Successfully removed' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.