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

Last change on this file since 16536 was 16421, checked in by Henrik Bettermann, 4 years ago

Add Microsoft Fee to schoolfee.

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1## $Id: test_utils.py 16421 2021-03-22 10:11:09Z 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(site['configuration'].next_matric_integer, 2)
45        self.assertEqual(msg, None)
46        # hnd_ft
47        self.student.matric_number = None
48        self.certificate.study_mode ='hnd_ft'
49        msg, mnumber = utils.setMatricNumber(self.student)
50        self.assertEqual(self.student.matric_number, 'dep1/HND/04/00001')
51        self.assertEqual(site['configuration'].next_matric_integer_2, 2)
52        self.assertEqual(msg, None)
53        # nd_pt
54        self.student.matric_number = None
55        self.certificate.study_mode ='nd_pt'
56        msg, mnumber = utils.setMatricNumber(self.student)
57        self.assertEqual(self.student.matric_number, 'dep1/ND/04/10001')
58        self.assertEqual(site['configuration'].next_matric_integer_3, 10002)
59        self.assertEqual(msg, None)
60        # hnd_pt
61        self.student.matric_number = None
62        self.certificate.study_mode ='hnd_pt'
63        msg, mnumber = utils.setMatricNumber(self.student)
64        self.assertEqual(self.student.matric_number, 'dep1/HND/04/10001')
65        self.assertEqual(site['configuration'].next_matric_integer_4, 10002)
66        self.assertEqual(msg, None)
67        return
68
69    def test_set_payment_details(self):
70        self.student['studycourse'].certificate.school_fee_1 = 6666.0
71        self.student['studycourse'].certificate.school_fee_2 = 7777.0
72        self.student['studycourse'].certificate.school_fee_3 = 8888.0
73        self.student['studycourse'].certificate.school_fee_4 = 9999.0
74        self.student['studycourse'].certificate.study_mode = 'hnd_ft'
75        self.student.nationality = u'NG'
76        self.student.lga = 'ebonyi_ukaba'
77        utils = getUtility(IStudentsUtils)
78        configuration = createObject('waeup.SessionConfiguration')
79        configuration.academic_session = 2005
80        self.app['configuration'].addSessionConfiguration(configuration)
81        error, payment = utils.setPaymentDetails('dep_sug',self.student)
82        self.assertEqual(payment.p_level, 100)
83        self.assertEqual(payment.p_session, 2004)
84        IWorkflowState(self.student).setState('returning')
85        # Returning students are paying for next session
86        error, payment = utils.setPaymentDetails('dep_sug',self.student)
87        self.assertEqual(payment.p_level, 200)
88        self.assertEqual(payment.p_session, 2005)
89        self.assertEqual(payment.amount_auth, 3150.0)
90        # Students can pay school fee if dep_sug and gns dues have been paid first.
91        error, payment = utils.setPaymentDetails('schoolfee',self.student)
92        self.assertEqual(error, u'You have to pay NADESU/SA/SUG and GNS Dues first.')
93        error, payment = utils.setPaymentDetails('dep_sug',self.student)
94        self.student['payments']['any_key'] = payment
95        error, payment = utils.setPaymentDetails('schoolfee',self.student)
96        self.assertEqual(error, u'You have to pay NADESU/SA/SUG and GNS Dues first.')
97
98        configuration.gns_1_fee = 1150.0
99        error, payment2 = utils.setPaymentDetails('gns_1',self.student)
100        self.student['payments']['any_key2'] = payment2
101        self.assertEqual(payment2.p_level, 200)
102        self.assertEqual(payment2.p_session, 2005)
103        self.assertEqual(payment2.amount_auth, 1150.0)
104        error, payment = utils.setPaymentDetails('schoolfee',self.student)
105
106        self.student['payments']['any_key'].p_state = 'paid'
107        self.student['payments']['any_key2'].p_state = 'paid'
108        error, payment = utils.setPaymentDetails('schoolfee',self.student)
109        self.assertEqual(error, None)
110        self.assertEqual(payment.p_level, 200)
111        self.assertEqual(payment.p_session, 2005)
112        self.assertEqual(payment.amount_auth, 16999.0) # now includes Microsoft Fee
113
Note: See TracBrowser for help on using the repository browser.