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

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

Change school fees algorithm. Do no longer distinguish between local and foreigner students.

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