Changeset 11596


Ignore:
Timestamp:
23 Apr 2014, 09:46:18 (11 years ago)
Author:
Henrik Bettermann
Message:

Reorganize tests.

Further adjust constructMatricNumber (see ticket).

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
1 added
2 edited

Legend:

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

    r11593 r11596  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 import os
    1918import shutil
    2019import tempfile
    21 import grok
    22 from StringIO import StringIO
    2320from hurry.workflow.interfaces import IWorkflowState
    2421from zope.component.hooks import setSite, clearSite
    2522from zope.component import getUtility, createObject
    26 from zope.interface import verify
    2723from waeup.kofa.app import University
    2824from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    2925from waeup.kofa.students.accommodation import BedTicket
    3026from waeup.kofa.testing import FunctionalTestCase
    31 from waeup.kofa.interfaces import (
    32     IExtFileStore, IFileStoreNameChooser)
    33 from waeup.kofa.students.interfaces import IStudentsUtils
    3427from waeup.aaue.testing import FunctionalLayer
    3528
     
    265258        return
    266259
    267     def test_get_returning_data(self):
    268         # Student is in level 100, session 2004 with verdict A
    269         utils = getUtility(IStudentsUtils)
    270         self.assertEqual(utils.getReturningData(self.student),(2005, 200))
    271         self.student['studycourse'].current_verdict = 'C'
    272         self.assertEqual(utils.getReturningData(self.student),(2005, 110))
    273         self.student['studycourse'].current_verdict = 'NEOR'
    274         self.assertEqual(utils.getReturningData(self.student),(2005, 100))
    275         return
    276 
    277     def test_set_payment_details(self):
    278         self.app['configuration']['2004'].gown_fee = 150.0
    279         self.app['configuration']['2004'].transfer_fee = 90.0
    280         self.app['configuration']['2004'].booking_fee = 150.0
    281         self.app['configuration']['2004'].maint_fee = 180.0
    282         self.app['configuration']['2004'].clearance_fee = 1234.0
    283         self.app['configuration']['2004'].school_fee = 6666.0
    284         utils = getUtility(IStudentsUtils)
    285 
    286         configuration = createObject('waeup.SessionConfiguration')
    287         configuration.academic_session = 2005
    288         self.app['configuration'].addSessionConfiguration(configuration)
    289         self.app['configuration']['2005'].school_fee = 7777.0
    290 
    291         error, payment = utils.setPaymentDetails('schoolfee',self.student)
    292         self.assertEqual(payment, None)
    293         self.assertEqual(error, u'Wrong state.')
    294 
    295         IWorkflowState(self.student).setState('cleared')
    296         error, payment = utils.setPaymentDetails('schoolfee',self.student)
    297         self.assertEqual(payment.p_level, 100)
    298         self.assertEqual(payment.p_session, 2004)
    299         self.assertEqual(payment.amount_auth, 6666.0)
    300         self.assertEqual(payment.p_item, u'CERT1')
    301         self.assertEqual(error, None)
    302 
    303         # Add penalty fee ...
    304         # ... for cleared
    305         self.app['configuration']['2004'].penalty_ug = 99.0
    306         # ... for returning
    307         self.app['configuration']['2005'].penalty_ug = 88.0
    308         error, payment = utils.setPaymentDetails('schoolfee',self.student)
    309         self.assertEqual(payment.amount_auth, 6765.0)
    310         IWorkflowState(self.student).setState('returning')
    311         error, payment = utils.setPaymentDetails('schoolfee',self.student)
    312         self.assertEqual(payment.p_level, 200)
    313         self.assertEqual(payment.p_session, 2005)
    314         self.assertEqual(payment.amount_auth, 7865.0)
    315         self.assertEqual(payment.p_item, u'CERT1')
    316         self.assertEqual(error, None)
    317 
    318         error, payment = utils.setPaymentDetails('clearance',self.student)
    319         self.assertEqual(payment.p_level, 100)
    320         self.assertEqual(payment.p_session, 2004)
    321         self.assertEqual(payment.amount_auth, 1234.0)
    322         self.assertEqual(payment.p_item, u'CERT1')
    323         self.assertEqual(error, None)
    324 
    325         error, payment = utils.setPaymentDetails('gown',self.student)
    326         self.assertEqual(payment.p_level, 100)
    327         self.assertEqual(payment.p_session, 2004)
    328         self.assertEqual(payment.amount_auth, 150.0)
    329         self.assertEqual(payment.p_item, u'')
    330         self.assertEqual(error, None)
    331 
    332         error, payment = utils.setPaymentDetails('hostel_maintenance',self.student)
    333         self.assertEqual(payment.p_level, 100)
    334         self.assertEqual(payment.p_session, 2004)
    335         self.assertEqual(payment.amount_auth, 180.0)
    336         self.assertEqual(payment.p_item, u'')
    337         self.assertEqual(error, None)
    338 
    339         error, payment = utils.setPaymentDetails('bed_allocation',self.student)
    340         self.assertEqual(payment.p_level, 100)
    341         self.assertEqual(payment.p_session, 2004)
    342         self.assertEqual(payment.amount_auth, 150.0)
    343         self.assertEqual(payment.p_item, u'')
    344         self.assertEqual(error, None)
    345 
    346         error, payment = utils.setPaymentDetails('transfer',self.student)
    347         self.assertEqual(payment.p_level, 100)
    348         self.assertEqual(payment.p_session, 2004)
    349         self.assertEqual(payment.amount_auth, 90.0)
    350         self.assertEqual(payment.p_item, u'')
    351         self.assertEqual(error, None)
    352 
    353         error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100)
    354         self.assertEqual(error, u'Previous session payment not yet implemented.')
    355         return
    356 
    357260    def deactivated_test_student_course_registration(self):
    358261
     
    429332        return
    430333
    431     def test_maxCredits(self):
    432         dummy = object()
    433         utils = getUtility(IStudentsUtils)
    434         self.assertEqual(utils.maxCredits(dummy), 48)
    435         return
    436 
    437     def test_set_matric_number(self):
    438         site = grok.getSite()
    439         utils = getUtility(IStudentsUtils)
    440         site['configuration'].next_matric_integer = 1
    441         self.student.matric_number = None
    442         msg, mnumber = utils.setMatricNumber(self.student)
    443         self.assertEqual(msg, None)
    444         self.assertEqual(mnumber, 1)
    445         self.assertEqual(self.student.matric_number, 'fac1/dep1/04/00001')
    446         self.assertEqual(site['configuration'].next_matric_integer, 2)
    447         # Part time have an extended matric number
    448         self.student.matric_number = None
    449         self.student['studycourse'].certificate.study_mode = 'ug_pt'
    450         msg, mnumber = utils.setMatricNumber(self.student)
    451         self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00002')
    452         # Foundation programme students don't get matric number.
    453         self.student.matric_number = None
    454         self.student['studycourse'].certificate.study_mode = 'found'
    455         msg, mnumber = utils.setMatricNumber(self.student)
    456         self.assertEqual(msg, 'Matriculation number cannot be set.')
    457         self.assertEqual(mnumber, None)
    458         # Certificate must be set.
    459         self.student.matric_number = None
    460         self.student['studycourse'].certificate = None
    461         msg, mnumber = utils.setMatricNumber(self.student)
    462         self.assertEqual(msg, 'No certificate assigned.')
    463         return
     334
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r11593 r11596  
    7171                      (5, '1st Class Honours'))
    7272
    73     def _constructMatricNumber(self, student, next_integer):
     73    def constructMatricNumber(self, student):
     74        next_integer = grok.getSite()['configuration'].next_matric_integer
     75        if next_integer == 0:
     76            return None
    7477        faccode = student.faccode
    7578        depcode = student.depcode
     
    7780        if student.current_mode in ('ug_pt', 'de_pt'):
    7881            return "PTP/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
    79         if student.current_mode in ('pg_ft', 'pg_pt'):
    80             return "SPS/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
    81         if student.current_mode == 'found':
    82             return None
    83         return "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
     82        #if student.current_mode in ('pg_ft', 'pg_pt'):
     83        #    return "SPS/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
     84        #if student.current_mode in ('dp_ft', 'dp_pt'):
     85        #    return "DIP/%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
     86        #if student.current_mode == 'found':
     87        #    return None
     88        #return "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer)
     89        return None
    8490
    8591    def getReturningData(self, student):
Note: See TracChangeset for help on using the changeset viewer.