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

Last change on this file since 15959 was 15360, checked in by Henrik Bettermann, 6 years ago

Configure dep_sug payment requirement properly.

  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1## $Id: test_utils.py 15360 2019-03-22 07:05:00Z 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 has been paid first.
91        error, payment = utils.setPaymentDetails('schoolfee',self.student)
92        self.assertEqual(error, u'You have to pay NADESU/SA/SUG 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 Dues first.')
97        self.student['payments']['any_key'].p_state = 'paid'
98        error, payment = utils.setPaymentDetails('schoolfee',self.student)
99        self.assertEqual(error, None)
100        self.assertEqual(payment.p_level, 200)
101        self.assertEqual(payment.p_session, 2005)
102        self.assertEqual(payment.amount_auth, 9999.0)
103
Note: See TracBrowser for help on using the repository browser.