1 | ## $Id: test_browser.py 17715 2024-03-13 21:34:26Z 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 mechanize import LinkNotFoundError |
---|
24 | from zope.securitypolicy.interfaces import IPrincipalRoleManager |
---|
25 | from zope.component.hooks import setSite, clearSite |
---|
26 | from zope.component import getUtility, createObject |
---|
27 | from zope.interface import verify |
---|
28 | from zope.event import notify |
---|
29 | from waeup.kofa.authentication import LocalRoleSetEvent |
---|
30 | from waeup.kofa.app import University |
---|
31 | from waeup.kofa.students.tests.test_browser import StudentsFullSetup |
---|
32 | from waeup.kofa.students.accommodation import BedTicket |
---|
33 | from waeup.kofa.testing import FunctionalTestCase |
---|
34 | from waeup.kofa.interfaces import ( |
---|
35 | IExtFileStore, IFileStoreNameChooser) |
---|
36 | from waeup.kofa.browser.tests.test_pdf import samples_dir |
---|
37 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
38 | from kofacustom.unidel.testing import FunctionalLayer |
---|
39 | |
---|
40 | |
---|
41 | class StudentsContainerUITests(StudentsFullSetup): |
---|
42 | # Tests for StudentsContainer class views and pages |
---|
43 | |
---|
44 | layer = FunctionalLayer |
---|
45 | |
---|
46 | def test_student_examclearance_slip(self): |
---|
47 | self.certificate.study_mode = 'ug_ft' |
---|
48 | # Student cant login if their password is not set |
---|
49 | IWorkflowState(self.student).setState('courses registered') |
---|
50 | self.browser.open(self.login_path) |
---|
51 | self.browser.getControl(name="form.login").value = self.student_id |
---|
52 | self.browser.getControl(name="form.password").value = 'spwd' |
---|
53 | self.browser.getControl("Login").click() |
---|
54 | self.assertMatches( |
---|
55 | '...You logged in...', self.browser.contents) |
---|
56 | self.browser.getLink("Base Data").click() |
---|
57 | ## Unidel changed it's mind again and again |
---|
58 | #self.assertRaises( |
---|
59 | # LinkNotFoundError, |
---|
60 | # self.browser.getLink, 'Download examination clearance slip') |
---|
61 | #self.browser.getLink("Download examination clearance slip").click() |
---|
62 | #self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') |
---|
63 | self.browser.getLink("Base Data").click() |
---|
64 | self.browser.getLink("Download examination clearance slip").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(), 'examclearance_slip.pdf') |
---|
68 | open(path, 'wb').write(self.browser.contents) |
---|
69 | print "Sample exampclearance_slip.pdf written to %s" % path |
---|