source: main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/tests/test_utils.py @ 17540

Last change on this file since 17540 was 17397, checked in by Henrik Bettermann, 19 months ago

Pt students do not pay SUD.

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1## $Id: test_utils.py 17397 2023-04-28 08:38:41Z 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.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.edopoly.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 = 1
38        self.student.matric_number = None
39        # nd_ft
40        self.certificate.study_mode ='nd_ft'
41        msg, mnumber = utils.setMatricNumber(self.student)
42        self.assertEqual(self.student.matric_number, 'fac1/ND/04/00001')
43        self.assertEqual(site['configuration'].next_matric_integer, 2)
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, 'fac1/HD/04/00001')
50        self.assertEqual(site['configuration'].next_matric_integer_2, 2)
51        self.assertEqual(msg, None)
52        # nd_pt
53        self.student.matric_number = None
54        self.certificate.study_mode ='nd_pt'
55        msg, mnumber = utils.setMatricNumber(self.student)
56        self.assertEqual(self.student.matric_number, 'fac1/PT/04/00001')
57        self.assertEqual(site['configuration'].next_matric_integer_3, 2)
58        self.assertEqual(msg, None)
59        return
60
61    def test_set_payment_details(self):
62        self.student['studycourse'].certificate.school_fee_1 = 6666.0
63        self.student['studycourse'].certificate.study_mode = 'nd_pt'
64        IWorkflowState(self.student).setState('returning')
65        #self.student.nationality = u'NG'
66        #self.student.lga = 'ebonyi_ukaba'
67        utils = getUtility(IStudentsUtils)
68        configuration = createObject('waeup.SessionConfiguration')
69        configuration.academic_session = 2005
70        self.app['configuration'].addSessionConfiguration(configuration)
71        self.app['configuration']['2004'].ict_entre_fee = 4170.0
72        self.app['configuration']['2005'].ict_entre_fee = 2180.0
73        self.app['configuration']['2004'].union_fee = 1234.0
74        self.app['configuration']['2005'].union_fee = 1434.0
75        error, payment = utils.setPaymentDetails('schoolfee',self.student)
76        self.assertEqual(error, u'Pay ICT fee(s) first.')
77        error, payment = utils.setPaymentDetails('ict_entre',self.student)
78        self.assertEqual(error, None)
79        self.assertEqual(payment.p_level, 200)
80        self.assertEqual(payment.p_session, 2005)
81        self.assertEqual(payment.amount_auth, 2180.0)
82        payment.p_state = 'paid'
83        self.student['payments']['any_key'] = payment
84        #error, payment = utils.setPaymentDetails('union',self.student)
85        #self.assertEqual(error, None)
86        #self.assertEqual(payment.p_level, 200)
87        #self.assertEqual(payment.p_session, 2005)
88        #self.assertEqual(payment.amount_auth, 1434.0)
89        #payment.p_state = 'paid'
90        #self.student['payments']['any_key_2'] = payment
91        error, payment = utils.setPaymentDetails('schoolfee',self.student)
92        self.assertEqual(error, None)
93        self.assertEqual(payment.p_level, 200)
94        self.assertEqual(payment.p_session, 2005)
95        self.assertEqual(payment.amount_auth, 6666.0)
96
97        IWorkflowState(self.student).setState('cleared')
98        error, payment = utils.setPaymentDetails('ict_entre',self.student)
99        self.assertEqual(error, None)
100        self.assertEqual(payment.p_level, 100)
101        self.assertEqual(payment.p_session, 2004)
102        self.assertEqual(payment.amount_auth, 4170.0)
103        payment.p_state = 'paid'
104        self.student['payments']['any_key_3'] = payment
105        error, payment = utils.setPaymentDetails('union',self.student)
106        self.assertEqual(error, None)
107        self.assertEqual(payment.p_level, 100)
108        self.assertEqual(payment.p_session, 2004)
109        self.assertEqual(payment.amount_auth, 1234.0)
110        payment.p_state = 'paid'
111        self.student['payments']['any_key_4'] = payment
112        error, payment = utils.setPaymentDetails('schoolfee',self.student)
113        self.assertEqual(error, None)
114        self.assertEqual(payment.p_level, 100)
115        self.assertEqual(payment.p_session, 2004)
116        self.assertEqual(payment.amount_auth, 6666.0)
117
118        IWorkflowState(self.student).setState('admitted')
119        error, payment = utils.setPaymentDetails('schoolfee',self.student)
120        self.assertEqual(error, u'Amount could not be determined.')
Note: See TracBrowser for help on using the repository browser.