Ignore:
Timestamp:
2 May 2012, 05:10:36 (13 years ago)
Author:
Henrik Bettermann
Message:

Add more tests.

File:
1 edited

Legend:

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

    r8306 r8320  
    2121from hurry.workflow.interfaces import IWorkflowState
    2222from zope.component.hooks import setSite, clearSite
     23from zope.component import getUtility
    2324from waeup.kofa.app import University
    2425from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    2526from waeup.kofa.testing import FunctionalTestCase
    2627from waeup.kofa.students.batching import StudentProcessor
     28from waeup.kofa.students.interfaces import IStudentsUtils
    2729from waeup.uniben.students.batching import CustomStudentProcessor
    2830from waeup.uniben.testing import FunctionalLayer
     31from waeup.uniben.students.utils import get_school_fee
     32
    2933
    3034STUDENT_SAMPLE_DATA = open(
     
    218222        self.assertMatches('...ticket created...',
    219223                           self.browser.contents)
     224        # In state admitted school fee can't be determined
    220225        IWorkflowState(self.student).setState('admitted')
    221226        self.browser.open(self.payments_path + '/addop')
     
    247252        self.assertTrue('Save' in self.browser.contents)
    248253
    249 
     254    def test_get_returning_data(self):
     255        # Student is in level 100, session 2004 with verdict A
     256        utils = getUtility(IStudentsUtils)
     257        self.assertEqual(utils.getReturningData(self.student),(2005, 200))
     258        self.student['studycourse'].current_verdict = 'C'
     259        self.assertEqual(utils.getReturningData(self.student),(2005, 110))
     260        self.student['studycourse'].current_verdict = 'D'
     261        self.assertEqual(utils.getReturningData(self.student),(2005, 100))
     262        return
     263
     264    def test_get_schoolfee(self):
     265        self.assertEqual(get_school_fee(self.student),0.0)
     266        IWorkflowState(self.student).setState('cleared')
     267        self.assertEqual(get_school_fee(self.student),40000.0)
     268        IWorkflowState(self.student).setState('returning')
     269        self.assertEqual(get_school_fee(self.student),20000.0)
     270        return
     271
     272    def test_get_payment_details(self):
     273        self.app['configuration']['2004'].gown_fee = 150.0
     274        self.app['configuration']['2004'].transfer_fee = 90.0
     275        self.app['configuration']['2004'].booking_fee = 150.0
     276        self.app['configuration']['2004'].maint_fee = 180.0
     277        utils = getUtility(IStudentsUtils)
     278        self.assertEqual(utils.getPaymentDetails('schoolfee',self.student),
     279            {'p_level': 100, 'p_session': 2004, 'amount': 0.0,
     280            'p_item': u'CERT1', 'error': u'Amount could not be determined.'}
     281            )
     282        self.assertEqual(utils.getPaymentDetails('clearance',self.student),
     283            {'p_level': 100, 'p_session': 2004, 'amount': 34250.0,
     284            'p_item': u'CERT1', 'error': u''}
     285            )
     286        self.assertEqual(utils.getPaymentDetails('gown',self.student),
     287            {'p_level': 100, 'p_session': 2004, 'amount': 150.0,
     288            'p_item': u'', 'error': u''}
     289            )
     290        self.assertEqual(utils.getPaymentDetails('hostel_maintenance',self.student),
     291            {'p_level': 100, 'p_session': 2004, 'amount': 180.0,
     292            'p_item': u'', 'error': u''}
     293            )
     294        self.assertEqual(utils.getPaymentDetails('bed_allocation',self.student),
     295            {'p_level': 100, 'p_session': 2004, 'amount': 150.0,
     296            'p_item': u'', 'error': u''}
     297            )
     298        self.assertEqual(utils.getPaymentDetails('transfer',self.student),
     299            {'p_level': 100, 'p_session': 2004, 'amount': 90.0,
     300            'p_item': u'', 'error': u''}
     301            )
     302        return
Note: See TracChangeset for help on using the changeset viewer.