1 | ## $Id: test_browser.py 16695 2021-11-03 15:38:36Z 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 | ## |
---|
18 | import os |
---|
19 | import shutil |
---|
20 | import tempfile |
---|
21 | from StringIO import StringIO |
---|
22 | from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo |
---|
23 | from zope.securitypolicy.interfaces import IPrincipalRoleManager |
---|
24 | from zope.component.hooks import setSite, clearSite |
---|
25 | from zope.component import getUtility, createObject |
---|
26 | from zope.interface import verify |
---|
27 | from zope.event import notify |
---|
28 | from waeup.kofa.authentication import LocalRoleSetEvent |
---|
29 | from waeup.kofa.app import University |
---|
30 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
31 | from waeup.kofa.students.accommodation import BedTicket |
---|
32 | from waeup.kofa.testing import FunctionalTestCase |
---|
33 | from waeup.kofa.browser.tests.test_pdf import samples_dir |
---|
34 | from waeup.kofa.interfaces import ( |
---|
35 | IExtFileStore, IFileStoreNameChooser) |
---|
36 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
37 | from kofacustom.edocons.testing import FunctionalLayer |
---|
38 | |
---|
39 | |
---|
40 | class StudentsContainerUITests(StudentsFullSetup): |
---|
41 | # Tests for StudentsContainer class views and pages |
---|
42 | |
---|
43 | layer = FunctionalLayer |
---|
44 | |
---|
45 | def test_dummytest(self): |
---|
46 | return |
---|
47 | |
---|
48 | class StudentUITests(StudentsFullSetup): |
---|
49 | # Tests for Student class views and pages |
---|
50 | |
---|
51 | layer = FunctionalLayer |
---|
52 | |
---|
53 | def test_student_admission_letters(self): |
---|
54 | self.certificate.study_mode = 'ug_ft' |
---|
55 | # Student cant login if their password is not set |
---|
56 | IWorkflowInfo(self.student).fireTransition('admit') |
---|
57 | self.browser.open(self.login_path) |
---|
58 | self.browser.getControl(name="form.login").value = self.student_id |
---|
59 | self.browser.getControl(name="form.password").value = 'spwd' |
---|
60 | self.browser.getControl("Login").click() |
---|
61 | self.assertMatches( |
---|
62 | '...You logged in...', self.browser.contents) |
---|
63 | self.browser.getLink("Base Data").click() |
---|
64 | self.browser.getLink("Download admission letter").click() |
---|
65 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
66 | self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') |
---|
67 | path = os.path.join(samples_dir(), 'admission_slip.pdf') |
---|
68 | open(path, 'wb').write(self.browser.contents) |
---|
69 | print "Sample PDF UG admission_slip.pdf written to %s" % path |
---|
70 | |
---|