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

Last change on this file since 17936 was 17727, checked in by Henrik Bettermann, 8 months ago

Students can set metric number if acceptance fee has been paid.

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