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

Last change on this file since 13998 was 13997, checked in by Henrik Bettermann, 9 years ago

Add button.

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