source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/tests/test_utils.py @ 16137

Last change on this file since 16137 was 16136, checked in by Henrik Bettermann, 5 years ago

Compulsory payments before tution fee can be made.

File size: 5.6 KB
Line 
1## $Id: test_utils.py 15763 2019-11-07 06:39: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.iuokada.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 = 21305
36        self.student.matric_number = None
37        msg, mnumber = utils.setMatricNumber(self.student)
38        self.assertEqual(self.student.matric_number, '04/021305')
39        self.assertEqual(msg, None)
40        return
41
42    def test_set_payment_details(self):
43        self.app['configuration']['2004'].book = 150.0
44        self.app['configuration']['2004'].develop = 90.0
45        self.app['configuration']['2004'].registration = 180.0
46        self.app['configuration']['2004'].municipal_fresh = 280.0
47        self.app['configuration']['2004'].pcf = 380.0
48        self.student['studycourse'].certificate.school_fee_2 = 6666.0
49        IWorkflowState(self.student).setState('cleared')
50        utils = getUtility(IStudentsUtils)
51        error, payment = utils.setPaymentDetails('schoolfee',self.student)
52        self.assertEqual(error,
53            'Registration Fee, Book Deposit, Development Fee, Municipal Fee, '
54            'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee.')
55        reg_payment = createObject('waeup.StudentOnlinePayment')
56        reg_payment.p_category = u'registration'
57        reg_payment.p_id = u'anyid'
58        reg_payment.p_state = u'paid'
59        reg_payment.p_session = 2004
60        self.student['payments']['anykey'] = reg_payment
61        error, payment = utils.setPaymentDetails('schoolfee',self.student)
62        self.assertEqual(error,
63            'Book Deposit, Development Fee, Municipal Fee, Parents Consultative '
64            'Forum (PCF) Fee must be paid before Tution Fee.')
65        IWorkflowState(self.student).setState('returning')
66        configuration = createObject('waeup.SessionConfiguration')
67        configuration.academic_session = 2005
68        self.app['configuration'].addSessionConfiguration(configuration)
69        self.app['configuration']['2005'].registration = 170.0
70        error, payment = utils.setPaymentDetails('schoolfee',self.student)
71        self.assertEqual(error,
72            'Registration Fee, Book Deposit, Development Fee, Municipal Fee, '
73            'Parents Consultative Forum (PCF) Fee must be paid before Tution Fee.')
74        reg_payment.p_session = 2005
75        error, payment = utils.setPaymentDetails('schoolfee',self.student)
76        self.assertEqual(error,
77            'Book Deposit, Development Fee, Municipal Fee, Parents Consultative '
78            'Forum (PCF) Fee must be paid before Tution Fee.')
79        pcf_payment = createObject('waeup.StudentOnlinePayment')
80        pcf_payment.p_category = u'parentsconsult'
81        pcf_payment.p_id = u'anyid'
82        pcf_payment.p_state = u'paid'
83        pcf_payment.p_session = 2005
84        self.student['payments']['anykey2'] = pcf_payment
85        error, payment = utils.setPaymentDetails('schoolfee',self.student)
86        self.assertEqual(error,
87            'Book Deposit, Development Fee, Municipal Fee must be paid before Tution Fee.')
88        munic_payment = createObject('waeup.StudentOnlinePayment')
89        munic_payment.p_category = u'municipal_fresh'
90        munic_payment.p_id = u'anyid'
91        munic_payment.p_state = u'paid'
92        munic_payment.p_session = 2005
93        self.student['payments']['anykey3'] = munic_payment
94        error, payment = utils.setPaymentDetails('schoolfee',self.student)
95        self.assertEqual(error,
96            'Book Deposit, Development Fee must be paid before Tution Fee.')
97        book_payment = createObject('waeup.StudentOnlinePayment')
98        book_payment.p_category = u'book'
99        book_payment.p_id = u'anyid'
100        book_payment.p_state = u'paid'
101        book_payment.p_session = 2005
102        self.student['payments']['anykey4'] = book_payment
103        develop_payment = createObject('waeup.StudentOnlinePayment')
104        develop_payment.p_category = u'develop'
105        develop_payment.p_id = u'anyid'
106        develop_payment.p_state = u'paid'
107        develop_payment.p_session = 2005
108        self.student['payments']['anykey5'] = develop_payment
109        error, payment = utils.setPaymentDetails('schoolfee',self.student)
110        self.assertEqual(error, None)
111        self.assertEqual(payment.p_level, 200)
112        self.assertEqual(payment.p_session, 2005)
113        self.assertEqual(payment.amount_auth, 6666.0)
114        return
Note: See TracBrowser for help on using the repository browser.