source: main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/students/tests/test_browser.py @ 15670

Last change on this file since 15670 was 14941, checked in by Henrik Bettermann, 7 years ago

Change all fees according to ticket comments 8 AND 4 and only according to comment 9.

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1## $Id: test_browser.py 14941 2018-01-22 11:57:06Z 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 os
19import shutil
20import tempfile
21from StringIO import StringIO
22from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
23from zope.securitypolicy.interfaces import IPrincipalRoleManager
24from zope.component.hooks import setSite, clearSite
25from zope.component import getUtility, createObject
26from zope.interface import verify
27from zope.event import notify
28from waeup.kofa.authentication import LocalRoleSetEvent
29from waeup.kofa.app import University
30from waeup.kofa.students.tests.test_browser import StudentsFullSetup
31from waeup.kofa.students.accommodation import BedTicket
32from waeup.kofa.browser.tests.test_pdf import samples_dir
33from waeup.kofa.testing import FunctionalTestCase
34from waeup.kofa.interfaces import (
35    IExtFileStore, IFileStoreNameChooser)
36from waeup.kofa.students.interfaces import IStudentsUtils
37from kofacustom.coewarri.testing import FunctionalLayer
38
39
40class StudentsContainerUITests(StudentsFullSetup):
41    # Tests for StudentsContainer class views and pages
42
43    layer = FunctionalLayer
44
45    def test_for_instalment_payments(self):
46
47        #configuration_1 = createObject('waeup.SessionConfiguration')
48        #configuration_1.academic_session = 2015
49        #self.app['configuration'].addSessionConfiguration(configuration_1)
50        self.student['studycourse'].certificate.study_mode = 'ug_ft'
51        self.student.nationality = u'NG'
52        # Fresh student
53        IWorkflowState(self.student).setState('cleared')
54        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
55        self.browser.open(self.payments_path + '/addop')
56        self.browser.open(self.payments_path + '/addop')
57        # Add first instalment
58        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
59        self.browser.getControl("Create ticket").click()
60        self.assertTrue('ticket created' in self.browser.contents)
61        self.browser.open(self.payments_path)
62        ctrl = self.browser.getControl(name='val_id')
63        p_id = ctrl.options[0]
64        self.browser.open(self.payments_path + '/' + p_id + '/approve')
65        # Add the second instalment ...
66        self.browser.open(self.payments_path + '/addop')
67        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
68        self.browser.getControl("Create ticket").click()
69        self.assertTrue('ticket created' in self.browser.contents)
70        # ... approve the second instalment ...
71        ctrl = self.browser.getControl(name='val_id')
72        p_id = ctrl.options[1]
73        self.browser.open(self.payments_path + '/' + p_id + '/approve')
74        self.assertEqual(self.student['payments'].values()[0].p_category, 'schoolfee_1')
75        self.assertEqual(self.student['payments'].values()[1].p_category, 'schoolfee_2')
76        # 79200 / 2 + 250
77        self.assertEqual(self.student['payments'].values()[0].amount_auth, 39850.0)
78        self.assertEqual(self.student['payments'].values()[1].amount_auth, 39850.0)
79        # The  two payments belong to the same session and level.
80        self.assertEqual(self.student['payments'].values()[0].p_session, 2004)
81        self.assertEqual(self.student['payments'].values()[0].p_level, 100)
82        self.assertEqual(self.student['payments'].values()[1].p_session, 2004)
83        self.assertEqual(self.student['payments'].values()[1].p_level, 100)
84
85        # Returning student
86        configuration_2 = createObject('waeup.SessionConfiguration')
87        configuration_2.academic_session = 2005
88        self.app['configuration'].addSessionConfiguration(configuration_2)
89        IWorkflowState(self.student).setState('returning')
90        self.browser.open(self.payments_path + '/addop')
91        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
92        self.browser.getControl("Create ticket").click()
93        self.browser.open(self.payments_path + '/addop')
94        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
95        self.browser.getControl("Create ticket").click()
96        self.browser.open(self.payments_path)
97        ctrl = self.browser.getControl(name='val_id')
98        # Nothing happens if we approve the 2nd instalment for session 2005
99        self.browser.open(self.payments_path + '/' + ctrl.options[3] + '/approve')
100        self.assertEqual(self.student.state, 'returning')
101        # Workflow transition is trigered if we approve the 1st indtalment
102        self.browser.open(self.payments_path + '/' + ctrl.options[2] + '/approve')
103        self.assertEqual(self.student.state, 'school fee paid')
104        self.assertEqual(self.student.current_level, 200)
105        self.assertEqual(self.student.current_session, 2005)
106        # 63100 / 2 + 250
107        self.assertEqual(self.student['payments'].values()[2].amount_auth, 37600.0)
108        self.assertEqual(self.student['payments'].values()[3].amount_auth, 37600.0)
109        # The last two payments belong to the same session and level.
110        self.assertEqual(self.student['payments'].values()[2].p_session, 2005)
111        self.assertEqual(self.student['payments'].values()[2].p_level, 200)
112        self.assertEqual(self.student['payments'].values()[3].p_session, 2005)
113        self.assertEqual(self.student['payments'].values()[3].p_level, 200)
114        return
115
116    def test_registration_pdf_slips(self):
117        # Student cant login if their password is not set
118        IWorkflowState(self.student).setState('school fee paid')
119        self.browser.open(self.login_path)
120        self.browser.getControl(name="form.login").value = self.student_id
121        self.browser.getControl(name="form.password").value = 'spwd'
122        self.browser.getControl("Login").click()
123        self.browser.getLink("Study Course").click()
124        self.browser.getLink("Add course list").click()
125        self.assertMatches('...Add current level 100 (Year 1)...',
126                           self.browser.contents)
127        self.browser.getControl("Create course list now").click()
128        # A level with one course ticket was created
129        self.browser.getLink("100").click()
130        self.browser.getLink("Download course registration slip").click()
131        self.assertEqual(self.browser.headers['Status'], '200 Ok')
132        self.assertEqual(self.browser.headers['Content-Type'],
133                         'application/pdf')
134        path = os.path.join(samples_dir(), 'course_registration_slip.pdf')
135        open(path, 'wb').write(self.browser.contents)
136        print "Sample PDF course_registration_slip.pdf written to %s" % path
Note: See TracBrowser for help on using the repository browser.