Ignore:
Timestamp:
5 May 2015, 12:17:58 (10 years ago)
Author:
Henrik Bettermann
Message:

Customize matric_number construction methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py

    r9614 r12904  
    11# -*- coding: utf-8 -*-
     2from hurry.workflow.interfaces import IWorkflowState
     3from zope.component import getUtility
    24from waeup.kofa.testing import FunctionalTestCase
    3 from zope.component import getUtility
     5from waeup.kofa.university.faculty import Faculty
     6from waeup.kofa.university.department import Department
    47from waeup.kofa.students.interfaces import IStudentsUtils
    58from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    69from waeup.kwarapoly.testing import FunctionalLayer
    710
    8 class BedAllocationTests(StudentsFullSetup):
     11class StudentsUtilsTests(StudentsFullSetup):
    912
    1013    layer = FunctionalLayer
     
    4346        self.assertEqual(acc_details['bt'], 'regular_male_fi')
    4447        return
     48
     49    def test_setMatricNumber(self):
     50        utils = getUtility(IStudentsUtils)
     51        self.student.matric_number = None
     52        msg, mnumber = utils.setMatricNumber(self.student)
     53        self.assertEqual(msg, 'Matriculation number cannot be set.')
     54        self.assertEqual(mnumber, None)
     55        self.student['studycourse'].entry_mode = 'nd_ft'
     56        self.student['studycourse'].entry_session = 2013
     57        msg, mnumber = utils.setMatricNumber(self.student)
     58        self.assertEqual(self.student.matric_number, 'ND/13/dep1/FT/001')
     59        self.assertEqual(
     60            self.app['faculties']['fac1']['dep1'].next_matric_dict,
     61            {2013: 2})
     62        # setting a new matric number in 2014, extends next_matric_dict
     63        self.student['studycourse'].entry_session = 2014
     64        self.student.matric_number = None
     65        msg, mnumber = utils.setMatricNumber(self.student)
     66        self.assertEqual(
     67            self.app['faculties']['fac1']['dep1'].next_matric_dict,
     68            {2013: 2, 2014: 2})
     69        # setting a new matric number in 2014 again, increases the counter
     70        self.student.matric_number = None
     71        msg, mnumber = utils.setMatricNumber(self.student)
     72        self.assertEqual(
     73            self.app['faculties']['fac1']['dep1'].next_matric_dict,
     74            {2013: 2, 2014: 3})
     75        # matric number must not exist
     76        msg, mnumber = utils.setMatricNumber(self.student)
     77        self.assertEqual(msg, 'Matriculation number already set.')
     78        # certificate must be set.
     79        self.student.matric_number = None
     80        self.student['studycourse'].certificate = None
     81        msg, mnumber = utils.setMatricNumber(self.student)
     82        self.assertEqual(msg, 'No certificate assigned.')
     83        return
Note: See TracChangeset for help on using the changeset viewer.