source: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py @ 14212

Last change on this file since 14212 was 14089, checked in by Henrik Bettermann, 8 years ago

No probation levels in AAUE.

  • Property svn:keywords set to Id
File size: 9.7 KB
Line 
1## $Id: test_utils.py 14089 2016-08-18 07:42:10Z henrik $
2##
3## Copyright (C) 2011 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.tests.test_browser import StudentsFullSetup
22from waeup.kofa.students.interfaces import IStudentsUtils
23from waeup.aaue.testing import FunctionalLayer
24
25class StudentsUtilsTests(StudentsFullSetup):
26
27    layer = FunctionalLayer
28
29    def test_get_returning_data(self):
30        # Student is in level 100, session 2004 with verdict A
31        utils = getUtility(IStudentsUtils)
32        self.assertEqual(utils.getReturningData(self.student),(2005, 200))
33        self.student['studycourse'].current_verdict = 'C'
34        self.assertEqual(utils.getReturningData(self.student),(2005, 200))
35        self.student['studycourse'].current_verdict = 'NEOR'
36        self.assertEqual(utils.getReturningData(self.student),(2005, 100))
37        return
38
39    def test_no_clearance_ac_code_created(self):
40        payment = createObject('waeup.StudentOnlinePayment')
41        payment.p_category = 'clearance'
42        self.student['payments']['any_id'] = payment
43        payment.approveStudentPayment()
44        # No activation code created.
45        self.assertEqual(payment.ac, None)
46
47    def test_set_payment_details(self):
48        self.app['configuration']['2004'].gown_fee = 150.0
49        self.app['configuration']['2004'].transfer_fee = 90.0
50        self.app['configuration']['2004'].booking_fee = 150.0
51        self.app['configuration']['2004'].maint_fee = 180.0
52        self.app['configuration']['2004'].clearance_fee_pg = 1234.0
53        self.app['configuration']['2004'].clearance_fee_fp = 3456.0
54        self.student['studycourse'].certificate.school_fee_1 = 6666.0
55        self.student['studycourse'].certificate.school_fee_2 = 7777.0
56        self.student['studycourse'].certificate.study_mode = 'special_pg_ft'
57        self.student.nationality = u'NG'
58        self.student.lga = 'ebonyi_ukaba'
59        utils = getUtility(IStudentsUtils)
60
61        configuration = createObject('waeup.SessionConfiguration')
62        configuration.academic_session = 2005
63        self.app['configuration'].addSessionConfiguration(configuration)
64
65        error, payment = utils.setPaymentDetails('schoolfee',self.student)
66        self.assertEqual(payment, None)
67        self.assertEqual(error, u'Wrong state.')
68        IWorkflowState(self.student).setState('cleared')
69        # School fee can be set.
70        error, payment = utils.setPaymentDetails('schoolfee',self.student)
71        self.assertEqual(payment.p_level, 100)
72        self.assertEqual(payment.p_session, 2004)
73        # 20000 Naira non-indigenous fee added
74        self.assertEqual(payment.amount_auth, 26666.0)
75        self.assertEqual(payment.p_item, u'CERT1')
76        self.assertEqual(error, None)
77        # Add penalty fee ...
78        # ... for cleared
79        self.app['configuration']['2004'].penalty_pg = 99.0
80        # ... for returning
81        self.app['configuration']['2005'].penalty_pg = 88.0
82        self.student.lga = 'edo_afuze'
83        error, payment = utils.setPaymentDetails('schoolfee',self.student)
84        self.assertEqual(payment.amount_auth, 6765.0)
85        IWorkflowState(self.student).setState('returning')
86        error, payment = utils.setPaymentDetails('schoolfee',self.student)
87        self.assertEqual(error, u'Personal data form is not properly filled.')
88        self.student.father_name = u'Rudolf'
89        error, payment = utils.setPaymentDetails('schoolfee_incl',self.student)
90        self.assertEqual(error, 'No additional fees required.')
91        error, payment = utils.setPaymentDetails('schoolfee',self.student)
92        self.assertEqual(payment.p_level, 200)
93        self.assertEqual(payment.p_session, 2005)
94        self.assertEqual(payment.amount_auth, 7865.0)
95        self.assertEqual(payment.p_item, u'CERT1')
96        self.assertEqual(error, None)
97
98        error, payment = utils.setPaymentDetails('clearance',self.student)
99        self.assertEqual(error, 'Acceptance Fee payments not allowed.')
100        IWorkflowState(self.student).setState('cleared')
101        error, payment = utils.setPaymentDetails('clearance_incl',self.student)
102        self.assertEqual(error, 'No additional fees required.')
103        error, payment = utils.setPaymentDetails('clearance',self.student)
104        self.assertEqual(payment.p_level, 100)
105        self.assertEqual(payment.p_session, 2004)
106        self.assertEqual(payment.amount_auth, 1234.0)
107        self.assertEqual(payment.p_item, u'CERT1')
108        self.assertEqual(error, None)
109
110        self.app['faculties']['fac1'].code = u'FP'
111        error, payment = utils.setPaymentDetails('clearance',self.student)
112        self.assertEqual(payment.p_level, 100)
113        self.assertEqual(payment.p_session, 2004)
114        self.assertEqual(payment.amount_auth, 3456.0)
115        self.assertEqual(payment.p_item, u'CERT1')
116        self.assertEqual(error, None)
117
118        error, payment = utils.setPaymentDetails('schoolfee',self.student, 2004, 100)
119        self.assertEqual(error, u'Previous session payment not yet implemented.')
120        return
121
122    def test_maxCredits(self):
123        dummy = object()
124        utils = getUtility(IStudentsUtils)
125        self.assertEqual(utils.maxCredits(dummy), 48)
126        return
127
128    def test_setMatricNumber(self):
129        IWorkflowState(self.student).setState('school fee paid')
130        site = grok.getSite()
131        utils = getUtility(IStudentsUtils)
132        site['configuration'].next_matric_integer = 1
133        site['configuration'].next_matric_integer_2 = 1
134        site['configuration'].next_matric_integer_3 = 1
135        site['configuration'].next_matric_integer_4 = 1
136        self.student.matric_number = None
137        #msg, mnumber = utils.setMatricNumber(self.student)
138        #self.assertEqual(msg, 'Matriculation number cannot be set.')
139        #payment = createObject('waeup.StudentOnlinePayment')
140        #payment.p_category = u'concessional'
141        #payment.p_id = u'anyid'
142        #payment.p_state = u'paid'
143        #self.student['payments']['anykey'] = payment
144        # Regular ft students have a matric number without leading constant.
145        msg, mnumber = utils.setMatricNumber(self.student)
146        self.assertEqual(self.student.matric_number, 'fac1/dep1/04/00001')
147        self.assertEqual(msg, None)
148        # Part time have an extended matric number with leading 'PTP'
149        # and a different counter which is next_matric_integer.
150        self.student.matric_number = None
151        self.student['studycourse'].certificate.study_mode = 'ug_pt'
152        msg, mnumber = utils.setMatricNumber(self.student)
153        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00001')
154        self.assertEqual(site['configuration'].next_matric_integer, 2)
155        # Students in faculty FBM get an extended matric number with leading 'CMS'
156        # and the regular counter which is next_matric_integer_2.
157        self.app['faculties']['fac1'].code = 'FBM'
158        self.student['studycourse'].certificate.study_mode = 'ug_ft'
159        self.student.matric_number = None
160        msg, mnumber = utils.setMatricNumber(self.student)
161        self.assertEqual(self.student.matric_number, 'CMS/FBM/dep1/04/00002')
162        self.assertEqual(site['configuration'].next_matric_integer_2, 3)
163        # PG Students get an extended matric number with leading 'AAU/SPS'
164        # and the pg  counter which is next_matric_integer_3.
165        self.app['faculties']['fac1'].code = 'ABC'
166        self.student['studycourse'].certificate.study_mode = 'special_pg_ft'
167        self.student.matric_number = None
168        self.certificate.degree = 'AGRB'
169        msg, mnumber = utils.setMatricNumber(self.student)
170        self.assertEqual(self.student.matric_number, 'AAU/SPS/ABC/dep1/04/AGRB/00001')
171        self.assertEqual(site['configuration'].next_matric_integer_3, 2)
172        self.student.matric_number = None
173        # students in IOE don't have a department
174        self.app['faculties']['fac1'].code = 'IOE'
175        msg, mnumber = utils.setMatricNumber(self.student)
176        self.assertEqual(self.student.matric_number, 'AAU/SPS/IOE/04/AGRB/00002')
177        # Diploma Students get a matric number with leading 'IOS'
178        # and the dp counter which is next_matric_integer_3.
179        self.student['studycourse'].certificate.study_mode = 'dp_ft'
180        self.student.matric_number = None
181        msg, mnumber = utils.setMatricNumber(self.student)
182        self.assertEqual(self.student.matric_number, 'IOE/DIP/04/00001')
183        self.assertEqual(site['configuration'].next_matric_integer_4, 2)
184        # Foundation programme students don't get matric number.
185        self.student.matric_number = None
186        self.student['studycourse'].certificate.study_mode = 'found'
187        msg, mnumber = utils.setMatricNumber(self.student)
188        self.assertEqual(msg, 'Matriculation number cannot be set.')
189        self.assertEqual(mnumber, None)
190        # Certificate must be set.
191        self.student.matric_number = None
192        self.student['studycourse'].certificate = None
193        msg, mnumber = utils.setMatricNumber(self.student)
194        self.assertEqual(msg, 'No certificate assigned.')
195        return
Note: See TracBrowser for help on using the repository browser.