source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py @ 15099

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

Remove some fields from certificate application form.

Remove passport picture requirement.

  • Property svn:keywords set to Id
File size: 14.6 KB
Line 
1## $Id: test_browser.py 15099 2018-08-06 06:48:42Z 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
19import datetime
20import pytz
21import os
22from zope.event import notify
23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
24from zope.component import createObject, getUtility
25from waeup.kofa.configuration import SessionConfiguration
26from waeup.kofa.interfaces import IUserAccount
27from waeup.kofa.applicants.container import ApplicantsContainer
28from waeup.kofa.browser.tests.test_pdf import samples_dir
29from waeup.aaue.testing import FunctionalLayer
30from waeup.kofa.applicants.tests.test_browser import (
31    ApplicantsFullSetup, container_name_1, session_1)
32
33class CustomApplicantUITest(ApplicantsFullSetup):
34    """Perform some browser tests.
35    """
36
37    layer = FunctionalLayer
38
39    def test_show_credentials_on_landing_page(self):
40        # An applicant can register himself.
41        self.applicant.reg_number = u'1234'
42        notify(grok.ObjectModifiedEvent(self.applicant))
43        self.browser.open('http://localhost/app/applicants/%s/' % container_name_1)
44        self.browser.getLink("Register for application").click()
45        # Fill the edit form with suitable values
46        self.browser.getControl(name="form.firstname").value = 'Klaus'
47        self.browser.getControl(name="form.lastname").value = 'Lutz'
48        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
49        self.browser.getControl("Send login credentials").click()
50        self.assertMatches('...Your registration was successful...',
51            self.browser.contents)
52        self.assertTrue('<td>Password:</td>' in self.browser.contents)
53        return
54
55    def test_payment(self):
56        configuration = SessionConfiguration()
57        configuration.academic_session = session_1
58        self.app['configuration'].addSessionConfiguration(configuration)
59        self.applicantscontainer.application_fee = 200.0
60        self.login()
61        self.browser.open(self.edit_path)
62        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
63        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
64        #self.browser.getControl(name="form.programme_type").value = ['regular']
65        self.browser.getControl(name="form.nationality").value = ['NG']
66        self.browser.getControl(name="form.sex").value = ['m']
67        self.browser.getControl(name="form.lastname").value = 'Merkel'
68        self.browser.getControl(name="form.fst_sit_fname").value = 'name'
69        self.browser.getControl(name="form.fst_sit_no").value = 'no'
70        self.browser.getControl(name="form.fst_sit_sc_pin").value = 'pin'
71        self.browser.getControl(name="form.fst_sit_sc_serial_number").value = 'serial'
72        self.browser.getControl(name="form.fst_sit_date").value = '09/09/2000'
73        self.browser.getControl(name="form.fst_sit_type").value = ['ssce']
74        self.browser.getControl("Save").click()
75        self.browser.getControl("Add online payment ticket").click()
76        self.assertMatches('...Payment ticket created...',
77                           self.browser.contents)
78        # Payment tickets can be downloaded without submitting the form.
79        self.browser.getLink("Download payment slip").click()
80        self.assertEqual(self.browser.headers['Content-Type'],
81                 'application/pdf')
82        # AAUE applicants never see the 'Remove Selected Tickets' button.
83        self.browser.open(self.edit_path)
84        self.assertFalse('Remove' in self.browser.contents)
85        return
86
87    def test_screening_invitation_download(self):
88        self.login()
89        self.applicant.screening_date = u'29th August 2016 @ 8:30 am'
90        self.applicant.screening_venue = u'Main Auditorium'
91        self.applicant.lastname = u'Cox'
92        self.applicant.firstname = u'Jo'
93        self.applicant.email = 'xx@yy.zz'
94        self.browser.open(self.view_path)
95        self.assertFalse("Download application slip" in self.browser.contents)
96        IWorkflowState(self.applicant).setState('submitted')
97        self.browser.open(self.view_path)
98        self.browser.getLink("screening invitation").click()
99        self.assertEqual(self.browser.headers['Status'], '200 Ok')
100        self.assertEqual(
101            self.browser.headers['Content-Type'], 'application/pdf')
102        path = os.path.join(samples_dir(), 'screening_invitation.pdf')
103        open(path, 'wb').write(self.browser.contents)
104        print "Sample PDF screening_invitation.pdf written to %s" % path
105        return
106
107    def test_application_slips(self):
108        delattr(ApplicantsContainer, 'prefix')
109        self.applicantscontainer.prefix = 'ude'
110        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
111        self.slip_path = self.view_path + '/application_slip.pdf'
112        self.browser.open(self.manage_path)
113        self.assertEqual(self.browser.headers['Status'], '200 Ok')
114        self.fill_correct_values()
115        self.browser.getControl("Save").click()
116        IWorkflowState(self.applicant).setState('admitted')
117        self.applicant.course_admitted = self.certificate
118        self.browser.open(self.manage_path)
119        self.browser.getLink("Download application slip").click()
120        self.assertEqual(self.browser.headers['Status'], '200 Ok')
121        self.assertEqual(self.browser.headers['Content-Type'],
122                         'application/pdf')
123        path = os.path.join(samples_dir(), 'application_slip.pdf')
124        open(path, 'wb').write(self.browser.contents)
125        print "Sample application_slip.pdf written to %s" % path
126
127    def test_transcript_application_manage(self):
128        # Add trans applicants container
129        self.transcontainer = ApplicantsContainer()
130        self.transcontainer.mode = 'create'
131        self.transcontainer.code = u'trans%s' % session_1
132        self.transcontainer.prefix = u'trans'
133        self.transcontainer.application_category = u'no'
134        self.transcontainer.year = session_1
135        self.transcontainer.application_fee = 300.0
136        self.transcontainer.title = u'This is the trans%s container' % session_1
137        self.app['applicants'][self.transcontainer.code] = self.transcontainer
138        delta = datetime.timedelta(days=10)
139        self.transcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
140        self.transcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
141        # Add applicant
142        transapplicant = createObject(u'waeup.Applicant')
143        transapplicant.firstname = u'Anna'
144        transapplicant.lastname = u'Post'
145        self.app['applicants'][self.transcontainer.code].addApplicant(transapplicant)
146        self.transapplication_number = transapplicant.application_number
147        self.transapplicant = self.app['applicants'][self.transcontainer.code][
148            self.transapplication_number]
149        self.transapplicant_path = ('http://localhost/app/applicants/trans%s/%s'
150            % (session_1, self.transapplication_number))
151        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
152        self.browser.open(self.transapplicant_path)
153        self.assertEqual(self.browser.headers['Status'], '200 Ok')
154        self.assertTrue("Dispatch Address" in self.browser.contents)
155
156    def _prepare_cert_container(self):
157        # Add cert applicants container
158        self.certcontainer = ApplicantsContainer()
159        self.certcontainer.mode = 'update'
160        self.certcontainer.code = u'cert%s' % session_1
161        self.certcontainer.prefix = u'cert'
162        self.certcontainer.application_category = u'no'
163        self.certcontainer.year = session_1
164        self.certcontainer.application_fee = 300.0
165        self.certcontainer.title = u'This is the cert%s container' % session_1
166        self.app['applicants'][self.certcontainer.code] = self.certcontainer
167        delta = datetime.timedelta(days=10)
168        self.certcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
169        self.certcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
170        # Add applicant
171        certapplicant = createObject(u'waeup.Applicant')
172        certapplicant.firstname = u'Anna'
173        certapplicant.lastname = u'Post'
174        certapplicant.reg_number = u'1234%s' % self.certcontainer.code
175        self.app['applicants'][self.certcontainer.code].addApplicant(certapplicant)
176        self.certapplication_number = certapplicant.application_number
177        self.certapplicant = self.app['applicants'][self.certcontainer.code][
178            self.certapplication_number]
179        self.certcontainer_path = ('http://localhost/app/applicants/cert%s'
180            % session_1)
181        self.certapplicant_path = ('http://localhost/app/applicants/cert%s/%s'
182            % (session_1, self.certapplication_number))
183
184    def test_certificate_request_manage(self):
185        self._prepare_cert_container()
186        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
187        self.browser.open(self.certapplicant_path)
188        self.assertEqual(self.browser.headers['Status'], '200 Ok')
189        #self.assertTrue("Dispatch Address" in self.browser.contents)
190
191    def test_certificate_request_update(self):
192        self._prepare_cert_container()
193        #IWorkflowState(self.applicant).setState('initialized')
194        self.browser.open(self.certcontainer_path + '/register')
195        self.browser.getControl(name="form.lastname").value = 'post'
196        self.browser.getControl(name="form.reg_number").value = '1234'
197        self.browser.getControl(name="form.email").value = 'new@yy.zz'
198        self.browser.getControl("Send login credentials").click()
199        # Yeah, we succeded ...
200        self.assertTrue('Your registration was successful.'
201            in self.browser.contents)
202
203    def test_pg_application_manage(self):
204        # Add pg applicants container
205        self.pgcontainer = ApplicantsContainer()
206        self.pgcontainer.mode = 'create'
207        self.pgcontainer.code = u'pgft%s' % session_1
208        self.pgcontainer.prefix = u'pgft'
209        self.pgcontainer.application_category = u'no'
210        self.pgcontainer.year = session_1
211        self.pgcontainer.application_fee = 300.0
212        self.pgcontainer.title = u'This is the pgft%s container' % session_1
213        self.app['applicants'][self.pgcontainer.code] = self.pgcontainer
214        delta = datetime.timedelta(days=10)
215        self.pgcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
216        self.pgcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
217        # Add applicant
218        pgapplicant = createObject(u'waeup.Applicant')
219        pgapplicant.firstname = u'Anna'
220        pgapplicant.lastname = u'Post'
221        self.app['applicants'][self.pgcontainer.code].addApplicant(pgapplicant)
222        self.pgapplication_number = pgapplicant.application_number
223        self.pgapplicant = self.app['applicants'][self.pgcontainer.code][
224            self.pgapplication_number]
225        self.pgapplicant_path = ('http://localhost/app/applicants/pgft%s/%s'
226            % (session_1, self.pgapplication_number))
227        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
228        self.browser.open(self.pgapplicant_path)
229        self.assertEqual(self.browser.headers['Status'], '200 Ok')
230        self.assertTrue("3rd Higher Education Record" in self.browser.contents)
231
232    def test_transcript_payment(self):
233        configuration = SessionConfiguration()
234        configuration.academic_session = session_1
235        self.app['configuration'].addSessionConfiguration(configuration)
236        # Add special application container
237        applicantscontainer = ApplicantsContainer()
238        applicantscontainer.year = session_1
239        applicantscontainer.application_fee = 200.0
240        applicantscontainer.code = u'trans1234'
241        applicantscontainer.prefix = 'trans'
242        applicantscontainer.title = u'This is a trans container'
243        applicantscontainer.application_category = 'no'
244        applicantscontainer.mode = 'create'
245        applicantscontainer.strict_deadline = True
246        delta = datetime.timedelta(days=10)
247        applicantscontainer.startdate = datetime.datetime.now(pytz.utc) - delta
248        applicantscontainer.enddate = datetime.datetime.now(pytz.utc) + delta
249        self.app['applicants']['trans1234'] = applicantscontainer
250        # Add an applicant
251        applicant = createObject('waeup.Applicant')
252        # reg_number is the only field which has to be preset here
253        # because managers are allowed to edit this required field
254        applicant.reg_number = u'12345'
255        self.app['applicants']['trans1234'].addApplicant(applicant)
256        IUserAccount(
257            self.app['applicants']['trans1234'][
258            applicant.application_number]).setPassword('apwd')
259        # Login
260        self.browser.open(self.login_path)
261        self.browser.getControl(
262            name="form.login").value = applicant.applicant_id
263        self.browser.getControl(name="form.password").value = 'apwd'
264        self.browser.getControl("Login").click()
265        self.browser.getLink("Edit").click()
266        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
267        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
268        self.browser.getControl(name="form.nationality").value = ['NG']
269        #self.browser.getControl(name="form.sex").value = ['f']
270        self.browser.getControl(name="form.firstname").value = 'Angela'
271        self.browser.getControl(name="form.lastname").value = 'Merkel'
272        self.browser.getControl(name="form.no_copies").value = ['3']
273        self.browser.getControl(name="form.course_studied").value = ['CERT1']
274        self.browser.getControl(name="form.matric_number").value = '234'
275        self.browser.getControl("Save").click()
276        self.browser.getControl("Add online payment ticket").click()
277        self.assertTrue('Payment ticket created' in self.browser.contents)
278        self.assertTrue('<span>100.0</span>' in self.browser.contents)
279        self.assertEqual(applicant.values()[0].amount_auth, 100.0)
280        return
281
282    def test_view_course_admitted(self):
283        self.applicant.course_admitted = self.certificate
284        self.login()
285        self.assertFalse('Admitted Course of Study' in self.browser.contents)
286        return
Note: See TracBrowser for help on using the repository browser.