source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/tests/test_utils.py @ 15288

Last change on this file since 15288 was 15288, checked in by Henrik Bettermann, 6 years ago

Add matric number construction tools.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1## $Id: test_utils.py 15288 2019-01-10 10:12:19Z henrik $
2##
3## Copyright (C) 2019 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19from hurry.workflow.interfaces import IWorkflowState
20from zope.component import getUtility, createObject
21from waeup.kofa.students.studylevel import StudentStudyLevel
22from waeup.kofa.students.tests.test_browser import StudentsFullSetup
23from waeup.kofa.students.interfaces import IStudentsUtils
24from waeup.kofa.students.studylevel import StudentStudyLevel
25from kofacustom.dspg.testing import FunctionalLayer
26
27class StudentsUtilsTests(StudentsFullSetup):
28
29    layer = FunctionalLayer
30
31    def test_setMatricNumber(self):
32        IWorkflowState(self.student).setState('school fee paid')
33        site = grok.getSite()
34        utils = getUtility(IStudentsUtils)
35        site['configuration'].next_matric_integer = 1
36        site['configuration'].next_matric_integer_2 = 1
37        site['configuration'].next_matric_integer_3 = 10001
38        site['configuration'].next_matric_integer_4 = 10001
39        self.student.matric_number = None
40        # nd_ft
41        self.certificate.study_mode ='nd_ft'
42        msg, mnumber = utils.setMatricNumber(self.student)
43        self.assertEqual(self.student.matric_number, 'dep1/ND/04/00001')
44        self.assertEqual(msg, None)
45        # hnd_ft
46        self.student.matric_number = None
47        self.certificate.study_mode ='hnd_ft'
48        msg, mnumber = utils.setMatricNumber(self.student)
49        self.assertEqual(self.student.matric_number, 'dep1/HND/04/00001')
50        self.assertEqual(msg, None)
51        # nd_pt
52        self.student.matric_number = None
53        self.certificate.study_mode ='nd_pt'
54        msg, mnumber = utils.setMatricNumber(self.student)
55        self.assertEqual(self.student.matric_number, 'dep1/ND/04/10001')
56        self.assertEqual(msg, None)
57        # hnd_pt
58        self.student.matric_number = None
59        self.certificate.study_mode ='hnd_pt'
60        msg, mnumber = utils.setMatricNumber(self.student)
61        self.assertEqual(self.student.matric_number, 'dep1/HND/04/10001')
62        self.assertEqual(msg, None)
63        return
Note: See TracBrowser for help on using the repository browser.