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

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

Omit certain fields only if application is in update mode (= ude, utme).

  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1## $Id: test_browser.py 14150 2016-09-02 09:03:03Z 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(name="form.sex").value = ['m']
65        self.browser.getControl(name="form.lastname").value = 'Merkel'
66        self.browser.getControl("Save").click()
67        self.browser.getControl("Add online payment ticket").click()
68        self.assertMatches('...Payment ticket created...',
69                           self.browser.contents)
70        # Payment tickets can be downloaded without submitting the form.
71        self.browser.getLink("Download payment slip").click()
72        self.assertEqual(self.browser.headers['Content-Type'],
73                 'application/pdf')
74        # AAUE applicants never see the 'Remove Selected Tickets' button.
75        self.browser.open(self.edit_path)
76        self.assertFalse('Remove' in self.browser.contents)
77        return
78
79    def test_screening_invitation_download(self):
80        self.login()
81        self.applicant.screening_date = u'29th August 2016 @ 8:30 am'
82        self.applicant.screening_venue = u'Main Auditorium'
83        self.applicant.lastname = u'Cox'
84        self.applicant.firstname = u'Jo'
85        self.applicant.email = 'xx@yy.zz'
86        self.browser.open(self.view_path)
87        self.browser.getLink("screening invitation").click()
88        self.assertEqual(self.browser.headers['Status'], '200 Ok')
89        self.assertEqual(
90            self.browser.headers['Content-Type'], 'application/pdf')
91        path = os.path.join(samples_dir(), 'screening_invitation.pdf')
92        open(path, 'wb').write(self.browser.contents)
93        print "Sample PDF screening_invitation.pdf written to %s" % path
94        return
95
96    def test_transcript_application_manage(self):
97        # Add trans applicants container
98        self.transcontainer = ApplicantsContainer()
99        self.transcontainer.mode = 'create'
100        self.transcontainer.code = u'trans%s' % session_1
101        self.transcontainer.prefix = u'trans'
102        self.transcontainer.application_category = u'no'
103        self.transcontainer.year = session_1
104        self.transcontainer.application_fee = 300.0
105        self.transcontainer.title = u'This is the trans%s container' % session_1
106        self.app['applicants'][self.transcontainer.code] = self.transcontainer
107        delta = datetime.timedelta(days=10)
108        self.transcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
109        self.transcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
110        # Add applicant
111        transapplicant = createObject(u'waeup.Applicant')
112        transapplicant.firstname = u'Anna'
113        transapplicant.lastname = u'Post'
114        self.app['applicants'][self.transcontainer.code].addApplicant(transapplicant)
115        self.transapplication_number = transapplicant.application_number
116        self.transapplicant = self.app['applicants'][self.transcontainer.code][
117            self.transapplication_number]
118        self.transapplicant_path = ('http://localhost/app/applicants/trans%s/%s'
119            % (session_1, self.transapplication_number))
120        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
121        self.browser.open(self.transapplicant_path)
122        self.assertEqual(self.browser.headers['Status'], '200 Ok')
123        self.assertTrue("Dispatch Address" in self.browser.contents)
124
125    def test_pg_application_manage(self):
126        # Add pg applicants container
127        self.pgcontainer = ApplicantsContainer()
128        self.pgcontainer.mode = 'create'
129        self.pgcontainer.code = u'pgft%s' % session_1
130        self.pgcontainer.prefix = u'pgft'
131        self.pgcontainer.application_category = u'no'
132        self.pgcontainer.year = session_1
133        self.pgcontainer.application_fee = 300.0
134        self.pgcontainer.title = u'This is the pgft%s container' % session_1
135        self.app['applicants'][self.pgcontainer.code] = self.pgcontainer
136        delta = datetime.timedelta(days=10)
137        self.pgcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
138        self.pgcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
139        # Add applicant
140        pgapplicant = createObject(u'waeup.Applicant')
141        pgapplicant.firstname = u'Anna'
142        pgapplicant.lastname = u'Post'
143        self.app['applicants'][self.pgcontainer.code].addApplicant(pgapplicant)
144        self.pgapplication_number = pgapplicant.application_number
145        self.pgapplicant = self.app['applicants'][self.pgcontainer.code][
146            self.pgapplication_number]
147        self.pgapplicant_path = ('http://localhost/app/applicants/pgft%s/%s'
148            % (session_1, self.pgapplication_number))
149        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
150        self.browser.open(self.pgapplicant_path)
151        self.assertEqual(self.browser.headers['Status'], '200 Ok')
152        self.assertTrue("3rd Higher Education Record" in self.browser.contents)
Note: See TracBrowser for help on using the repository browser.