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

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

Add more hq fields.

Re-organize OMIT field structure in views.

  • Property svn:keywords set to Id
File size: 6.2 KB
Line 
1## $Id: test_browser.py 13545 2015-12-16 08:45:50Z 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
21from zope.event import notify
22from zope.component import createObject, getUtility
23from waeup.kofa.configuration import SessionConfiguration
24from waeup.kofa.applicants.container import ApplicantsContainer
25from waeup.aaue.testing import FunctionalLayer
26from waeup.kofa.applicants.tests.test_browser import (
27    ApplicantsFullSetup, container_name_1, session_1)
28
29class CustomApplicantUITest(ApplicantsFullSetup):
30    """Perform some browser tests.
31    """
32
33    layer = FunctionalLayer
34
35    def test_show_credentials_on_landing_page(self):
36        # An applicant can register himself.
37        self.applicant.reg_number = u'1234'
38        notify(grok.ObjectModifiedEvent(self.applicant))
39        self.browser.open('http://localhost/app/applicants/%s/' % container_name_1)
40        self.browser.getLink("Register for application").click()
41        # Fill the edit form with suitable values
42        self.browser.getControl(name="form.firstname").value = 'Klaus'
43        self.browser.getControl(name="form.lastname").value = 'Lutz'
44        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
45        self.browser.getControl("Send login credentials").click()
46        self.assertMatches('...Your registration was successful...',
47            self.browser.contents)
48        self.assertTrue('<td>Password:</td>' in self.browser.contents)
49        return
50
51    def test_payment_slip_download_warning(self):
52        configuration = SessionConfiguration()
53        configuration.academic_session = session_1
54        configuration.application_fee = 200.0
55        self.app['configuration'].addSessionConfiguration(configuration)
56        self.login()
57        self.browser.open(self.edit_path)
58        self.fill_correct_values()
59        self.browser.getControl(name="form.programme_type").value = ['regular']
60        self.browser.getControl(name="form.nationality").value = ['NG']
61        self.browser.getControl("Save").click()
62        self.browser.getControl("Add online payment ticket").click()
63        self.assertMatches('...Payment ticket created...',
64                           self.browser.contents)
65        # Payment tickets can be downloaded without submitting the form.
66        self.browser.getLink("Download payment slip").click()
67        self.assertEqual(self.browser.headers['Content-Type'],
68                 'application/pdf')
69        return
70
71    def test_transcript_application_manage(self):
72        # Add trans applicants container
73        self.transcontainer = ApplicantsContainer()
74        self.transcontainer.mode = 'create'
75        self.transcontainer.code = u'trans%s' % session_1
76        self.transcontainer.prefix = u'trans'
77        self.transcontainer.application_category = u'no'
78        self.transcontainer.year = session_1
79        self.transcontainer.application_fee = 300.0
80        self.transcontainer.title = u'This is the trans%s container' % session_1
81        self.app['applicants'][self.transcontainer.code] = self.transcontainer
82        delta = datetime.timedelta(days=10)
83        self.transcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
84        self.transcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
85        # Add applicant
86        transapplicant = createObject(u'waeup.Applicant')
87        transapplicant.firstname = u'Anna'
88        transapplicant.lastname = u'Post'
89        self.app['applicants'][self.transcontainer.code].addApplicant(transapplicant)
90        self.transapplication_number = transapplicant.application_number
91        self.transapplicant = self.app['applicants'][self.transcontainer.code][
92            self.transapplication_number]
93        self.transapplicant_path = ('http://localhost/app/applicants/trans%s/%s'
94            % (session_1, self.transapplication_number))
95        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
96        self.browser.open(self.transapplicant_path)
97        self.assertEqual(self.browser.headers['Status'], '200 Ok')
98        self.assertTrue("Dispatch Address" in self.browser.contents)
99
100    def test_pg_application_manage(self):
101        # Add pg applicants container
102        self.pgcontainer = ApplicantsContainer()
103        self.pgcontainer.mode = 'create'
104        self.pgcontainer.code = u'pgft%s' % session_1
105        self.pgcontainer.prefix = u'pgft'
106        self.pgcontainer.application_category = u'no'
107        self.pgcontainer.year = session_1
108        self.pgcontainer.application_fee = 300.0
109        self.pgcontainer.title = u'This is the pgft%s container' % session_1
110        self.app['applicants'][self.pgcontainer.code] = self.pgcontainer
111        delta = datetime.timedelta(days=10)
112        self.pgcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
113        self.pgcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
114        # Add applicant
115        pgapplicant = createObject(u'waeup.Applicant')
116        pgapplicant.firstname = u'Anna'
117        pgapplicant.lastname = u'Post'
118        self.app['applicants'][self.pgcontainer.code].addApplicant(pgapplicant)
119        self.pgapplication_number = pgapplicant.application_number
120        self.pgapplicant = self.app['applicants'][self.pgcontainer.code][
121            self.pgapplication_number]
122        self.pgapplicant_path = ('http://localhost/app/applicants/pgft%s/%s'
123            % (session_1, self.pgapplication_number))
124        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
125        self.browser.open(self.pgapplicant_path)
126        self.assertEqual(self.browser.headers['Status'], '200 Ok')
127        self.assertTrue("3rd Higher Education Record" in self.browser.contents)
Note: See TracBrowser for help on using the repository browser.