Ignore:
Timestamp:
16 Jan 2016, 15:01:09 (9 years ago)
Author:
Henrik Bettermann
Message:

Add fields, permissions, browser views and buttons to enable financial clearance by bursory officers.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests
Files:
2 edited

Legend:

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

    r12985 r13620  
    2525from zope.component import getUtility, createObject
    2626from zope.interface import verify
     27from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2728from waeup.kofa.app import University
    2829from waeup.kofa.students.tests.test_browser import (
     
    347348        self.assertTrue(
    348349            'Form has been saved' in self.browser.contents)
     350
     351    def test_financial_clearance(self):
     352        self.app['users'].addUser('mrbursary', 'mrbursarysecret')
     353        self.app['users']['mrbursary'].email = 'mrbursary@foo.ng'
     354        self.app['users']['mrbursary'].title = u'Carlo Pitter'
     355        # Clearance officers needs to get
     356        # the StudentsOfficer site role
     357        prmglobal = IPrincipalRoleManager(self.app)
     358        prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrbursary')
     359        # Assign BursaryOfficer role
     360        prmglobal.assignRoleToPrincipal('waeup.BursaryOfficer', 'mrbursary')
     361        # Login
     362        self.browser.open(self.login_path)
     363        self.browser.getControl(name="form.login").value = 'mrbursary'
     364        self.browser.getControl(name="form.password").value = 'mrbursarysecret'
     365        self.browser.getControl("Login").click()
     366        # BO can see his roles
     367        self.browser.getLink("My Roles").click()
     368        self.assertMatches(
     369            '...<div>Bursary Officer</div>...',
     370            self.browser.contents)
     371        # BO can view student record
     372        self.browser.open(self.student_path)
     373        prmglobal.assignRoleToPrincipal('waeup.BursaryOfficer', 'mrbursary')
     374        self.browser.open(self.student_path)
     375        # BO can see clearance button ...
     376        self.assertTrue(
     377            'Clear student financially' in self.browser.contents)
     378        # ... but not withdraw button
     379        self.assertFalse(
     380            'Withdraw financial clearance' in self.browser.contents)
     381        # BO can clear student
     382        self.browser.getLink("Clear student financially").click()
     383        self.assertTrue(
     384            'Student has been financially cleared' in self.browser.contents)
     385        # Name of BO and date have been stored
     386        self.assertEqual(self.student.financially_cleared_by, 'Carlo Pitter')
     387        self.assertMatches(
     388            '<YYYY-MM-DD hh:mm:ss>',
     389            self.student.financial_clearance_date.strftime(
     390                "%Y-%m-%d %H:%M:%S"))
     391        # BO can't see clearance button ...
     392        self.assertFalse(
     393            'Clear student financially' in self.browser.contents)
     394        # ... but withdraw button and can withdraw clearance
     395        self.browser.getLink("Withdraw financial clearance").click()
     396        self.assertTrue(
     397            'Financial clearance withdrawn' in self.browser.contents)
     398        # Name of BO and date have been deleted
     399        self.assertEqual(self.student.financially_cleared_by, None)
     400        self.assertEqual(self.student.financial_clearance_date, None)
     401        # Clearance is logged
     402        logfile = os.path.join(
     403            self.app['datacenter'].storage, 'logs', 'students.log')
     404        logcontent = open(logfile).read()
     405        self.assertTrue(
     406            'mrbursary - kofacustom.nigeria.students.browser.ClearStudentFinancially'
     407            ' - K1000000 - financially cleared' in logcontent)
     408        self.assertTrue(
     409            'mrbursary - kofacustom.nigeria.students.browser.WithdrawFinancialClearance'
     410            ' - K1000000 - financial clearance withdrawn' in logcontent)
     411        # Clearance is also stored in the history
     412        self.browser.open(self.history_path)
     413        self.assertMatches(
     414            '...2016-01-16 15:50:48 WAT - Financially cleared by Carlo Pitter...',
     415            self.browser.contents)
     416        self.assertMatches(
     417            '...2016-01-16 15:50:48 WAT - Financial clearance withdrawn by Carlo Pitter...',
     418            self.browser.contents)
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py

    r13109 r13620  
    6868            'clr_code,date_of_birth,def_adm,disabled,email,emp2_end,'
    6969            'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,'
    70             'emp_reason,emp_start,employer,employer2,firstname,former_matric,'
     70            'emp_reason,emp_start,employer,employer2,'
     71            'financial_clearance_date,financially_cleared_by,'
     72            'firstname,former_matric,'
    7173            'fst_sit_date,fst_sit_fname,fst_sit_no,fst_sit_results,'
    7274            'fst_sit_type,hq2_degree,hq2_disc,hq2_matric_no,hq2_school,'
     
    8284            'current_level,current_session\r\nmy adm code,,,,'
    8385            '"[(\'accounts\', \'A\')]",my clr code,1981-02-04#,,,'
    84             'anna@sample.com,,,,,,,,,,,Anna,,,,,"[(\'accounts\', \'A\')]"'
     86            'anna@sample.com,,,,,,,,,,,,,Anna,,,,,"[(\'accounts\', \'A\')]"'
    8587            ',,,,,,,,,,,,,,,,Tester,,,234,M.,NG,,,,,,,,,'
    8688            '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,,123,,,,,'
Note: See TracChangeset for help on using the changeset viewer.