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

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

Remove course_admitted from application slip.

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