1 | ## $Id: test_browser.py 15185 2018-10-12 15:51:59Z 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.students.interfaces import IStudentsUtils |
---|
37 | from waeup.kofa.browser.tests.test_pdf import samples_dir |
---|
38 | from kofacustom.edopoly.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_dummytest(self): |
---|
47 | return |
---|
48 | |
---|
49 | class StudentUITests(StudentsFullSetup): |
---|
50 | """Tests for customized student class views and pages |
---|
51 | """ |
---|
52 | |
---|
53 | layer = FunctionalLayer |
---|
54 | |
---|
55 | def setUp(self): |
---|
56 | super(StudentUITests, self).setUp() |
---|
57 | |
---|
58 | |
---|
59 | def test_medical_laboratory_form(self): |
---|
60 | self.browser.open(self.login_path) |
---|
61 | self.browser.getControl(name="form.login").value = self.student_id |
---|
62 | self.browser.getControl(name="form.password").value = 'spwd' |
---|
63 | self.browser.getControl("Login").click() |
---|
64 | self.assertRaises( |
---|
65 | LinkNotFoundError, |
---|
66 | self.browser.getLink, 'Download medical laboratory request form') |
---|
67 | # Add medical fee payment ticket |
---|
68 | self.app['configuration']['2004'].medical = 180.0 |
---|
69 | payment = createObject('waeup.StudentOnlinePayment') |
---|
70 | payment.p_category = u'medical' |
---|
71 | payment.p_session = self.student.current_session |
---|
72 | payment.p_id = u'anyid' |
---|
73 | payment.p_state = u'paid' |
---|
74 | self.student['payments']['anykey'] = payment |
---|
75 | self.browser.open(self.student_path) |
---|
76 | self.browser.getLink("Download medical laboratory request form").click() |
---|
77 | self.assertEqual(self.browser.headers['Status'], '200 Ok') |
---|
78 | self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') |
---|
79 | path = os.path.join(samples_dir(), 'medical_laboratory_form.pdf') |
---|
80 | open(path, 'wb').write(self.browser.contents) |
---|
81 | print "Sample PDF medical_laboratory_form.pdf written to %s" % path |
---|