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

Last change on this file since 14027 was 14027, checked in by Henrik Bettermann, 8 years ago

AAUE applicants are not allowed to remove payment tickets.

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1## $Id: test_browser.py 14027 2016-07-13 04:36:41Z 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 zope.component import createObject, getUtility
24from waeup.kofa.configuration import SessionConfiguration
25from waeup.kofa.applicants.container import ApplicantsContainer
26from waeup.kofa.browser.tests.test_pdf import samples_dir
27from waeup.aaue.testing import FunctionalLayer
28from waeup.kofa.applicants.tests.test_browser import (
29    ApplicantsFullSetup, container_name_1, session_1)
30
31class CustomApplicantUITest(ApplicantsFullSetup):
32    """Perform some browser tests.
33    """
34
35    layer = FunctionalLayer
36
37    def test_show_credentials_on_landing_page(self):
38        # An applicant can register himself.
39        self.applicant.reg_number = u'1234'
40        notify(grok.ObjectModifiedEvent(self.applicant))
41        self.browser.open('http://localhost/app/applicants/%s/' % container_name_1)
42        self.browser.getLink("Register for application").click()
43        # Fill the edit form with suitable values
44        self.browser.getControl(name="form.firstname").value = 'Klaus'
45        self.browser.getControl(name="form.lastname").value = 'Lutz'
46        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
47        self.browser.getControl("Send login credentials").click()
48        self.assertMatches('...Your registration was successful...',
49            self.browser.contents)
50        self.assertTrue('<td>Password:</td>' in self.browser.contents)
51        return
52
53    def test_payment(self):
54        configuration = SessionConfiguration()
55        configuration.academic_session = session_1
56        self.app['configuration'].addSessionConfiguration(configuration)
57        self.applicantscontainer.application_fee = 200.0
58        self.login()
59        self.browser.open(self.edit_path)
60        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
61        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
62        #self.browser.getControl(name="form.programme_type").value = ['regular']
63        self.browser.getControl(name="form.nationality").value = ['NG']
64        self.browser.getControl("Save").click()
65        self.browser.getControl("Add online payment ticket").click()
66        self.assertMatches('...Payment ticket created...',
67                           self.browser.contents)
68        # Payment tickets can be downloaded without submitting the form.
69        self.browser.getLink("Download payment slip").click()
70        self.assertEqual(self.browser.headers['Content-Type'],
71                 'application/pdf')
72        # AAUE applicants never see the 'Remove Selected Tickets' button.
73        self.browser.open(self.edit_path)
74        self.assertFalse('Remove' in self.browser.contents)
75        return
76
77    def test_screening_invitation_download(self):
78        self.login()
79        self.applicant.screening_date = u'29th August 2016 @ 8:30 am'
80        self.applicant.screening_venue = u'Main Auditorium'
81        self.applicant.lastname = u'Cox'
82        self.applicant.firstname = u'Jo'
83        self.applicant.email = 'xx@yy.zz'
84        self.browser.open(self.view_path)
85        self.browser.getLink("screening invitation").click()
86        self.assertEqual(self.browser.headers['Status'], '200 Ok')
87        self.assertEqual(
88            self.browser.headers['Content-Type'], 'application/pdf')
89        path = os.path.join(samples_dir(), 'screening_invitation.pdf')
90        open(path, 'wb').write(self.browser.contents)
91        print "Sample PDF screening_invitation.pdf written to %s" % path
92        return
93
94    def test_transcript_application_manage(self):
95        # Add trans applicants container
96        self.transcontainer = ApplicantsContainer()
97        self.transcontainer.mode = 'create'
98        self.transcontainer.code = u'trans%s' % session_1
99        self.transcontainer.prefix = u'trans'
100        self.transcontainer.application_category = u'no'
101        self.transcontainer.year = session_1
102        self.transcontainer.application_fee = 300.0
103        self.transcontainer.title = u'This is the trans%s container' % session_1
104        self.app['applicants'][self.transcontainer.code] = self.transcontainer
105        delta = datetime.timedelta(days=10)
106        self.transcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
107        self.transcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
108        # Add applicant
109        transapplicant = createObject(u'waeup.Applicant')
110        transapplicant.firstname = u'Anna'
111        transapplicant.lastname = u'Post'
112        self.app['applicants'][self.transcontainer.code].addApplicant(transapplicant)
113        self.transapplication_number = transapplicant.application_number
114        self.transapplicant = self.app['applicants'][self.transcontainer.code][
115            self.transapplication_number]
116        self.transapplicant_path = ('http://localhost/app/applicants/trans%s/%s'
117            % (session_1, self.transapplication_number))
118        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
119        self.browser.open(self.transapplicant_path)
120        self.assertEqual(self.browser.headers['Status'], '200 Ok')
121        self.assertTrue("Dispatch Address" in self.browser.contents)
122
123    def test_pg_application_manage(self):
124        # Add pg applicants container
125        self.pgcontainer = ApplicantsContainer()
126        self.pgcontainer.mode = 'create'
127        self.pgcontainer.code = u'pgft%s' % session_1
128        self.pgcontainer.prefix = u'pgft'
129        self.pgcontainer.application_category = u'no'
130        self.pgcontainer.year = session_1
131        self.pgcontainer.application_fee = 300.0
132        self.pgcontainer.title = u'This is the pgft%s container' % session_1
133        self.app['applicants'][self.pgcontainer.code] = self.pgcontainer
134        delta = datetime.timedelta(days=10)
135        self.pgcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
136        self.pgcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
137        # Add applicant
138        pgapplicant = createObject(u'waeup.Applicant')
139        pgapplicant.firstname = u'Anna'
140        pgapplicant.lastname = u'Post'
141        self.app['applicants'][self.pgcontainer.code].addApplicant(pgapplicant)
142        self.pgapplication_number = pgapplicant.application_number
143        self.pgapplicant = self.app['applicants'][self.pgcontainer.code][
144            self.pgapplication_number]
145        self.pgapplicant_path = ('http://localhost/app/applicants/pgft%s/%s'
146            % (session_1, self.pgapplication_number))
147        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
148        self.browser.open(self.pgapplicant_path)
149        self.assertEqual(self.browser.headers['Status'], '200 Ok')
150        self.assertTrue("3rd Higher Education Record" in self.browser.contents)
Note: See TracBrowser for help on using the repository browser.