source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/tests/test_browser.py @ 17808

Last change on this file since 17808 was 16155, checked in by Henrik Bettermann, 4 years ago

DSPG requires total credits on semester basis.

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1## $Id: test_browser.py 16155 2020-07-09 07:23:40Z 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 os
19import shutil
20import tempfile
21from StringIO import StringIO
22from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
23from zope.securitypolicy.interfaces import IPrincipalRoleManager
24from zope.component.hooks import setSite, clearSite
25from zope.component import getUtility, createObject
26from zope.interface import verify
27from zope.event import notify
28from waeup.kofa.authentication import LocalRoleSetEvent
29from waeup.kofa.app import University
30from waeup.kofa.students.tests.test_browser import StudentsFullSetup
31from waeup.kofa.students.accommodation import BedTicket
32from waeup.kofa.testing import FunctionalTestCase
33from waeup.kofa.browser.tests.test_pdf import samples_dir
34from waeup.kofa.interfaces import (
35    IExtFileStore, IFileStoreNameChooser)
36from waeup.kofa.students.interfaces import IStudentsUtils
37from kofacustom.dspg.testing import FunctionalLayer
38
39
40class StudentsContainerUITests(StudentsFullSetup):
41    # Tests for StudentsContainer class views and pages
42
43    layer = FunctionalLayer
44
45    def test_dummytest(self):
46        return
47
48    def test_student_clearance(self):
49        # Student cant login if their password is not set
50        IWorkflowInfo(self.student).fireTransition('admit')
51        self.browser.open(self.login_path)
52        self.browser.getControl(name="form.login").value = self.student_id
53        self.browser.getControl(name="form.password").value = 'spwd'
54        self.browser.getControl("Login").click()
55        self.assertMatches(
56            '...You logged in...', self.browser.contents)
57        # Admitted student can upload a passport picture
58        #self.browser.open(self.student_path + '/change_portrait')
59        #ctrl = self.browser.getControl(name='passportuploadedit')
60        #file_obj = open(SAMPLE_IMAGE, 'rb')
61        #file_ctrl = ctrl.mech_control
62        #file_ctrl.add_file(file_obj, filename='my_photo.jpg')
63        #self.browser.getControl(
64         #   name='upload_passportuploadedit').click()
65        #elf.assertTrue(
66         #   'src="http://localhost/app/students/K1000000/passport.jpg"'
67         #   in self.browser.contents)
68        ## Students can open admission letter
69        self.browser.getLink("Base Data").click()
70        self.browser.getLink("Download admission letter").click()
71        self.assertEqual(self.browser.headers['Status'], '200 Ok')
72        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
73        path = os.path.join(samples_dir(), 'admission_slip.pdf')
74        open(path, 'wb').write(self.browser.contents)
75        print "Sample PDF admission_slip.pdf written to %s" % path
76
77    def test_student_course_registration(self):
78        IWorkflowState(self.student).setState('school fee paid')
79        self.student['studycourse'].current_level = 200
80        self.browser.open(self.login_path)
81        self.browser.getControl(name="form.login").value = self.student_id
82        self.browser.getControl(name="form.password").value = 'spwd'
83        self.browser.getControl("Login").click()
84        self.browser.open(self.student_path + '/studycourse/add')
85        self.browser.getControl("Create course list now").click()
86        # A level with one course ticket was created
87        self.assertEqual(self.student['studycourse']['200'].number_of_tickets, 0)
88        self.browser.getLink("200").click()
89        self.browser.getLink("Edit course list").click()
90        self.browser.getLink("here").click()
91        self.browser.getControl(name="form.course").value = ['COURSE1']
92        self.course.credits = 41
93        self.browser.getControl("Add course ticket").click()
94        self.assertTrue(
95            'Maximum credits (40) in 1st semester exceeded.' in self.browser.contents)
96        self.course.credits = 39
97        self.browser.getControl("Add course ticket").click()
98        self.assertTrue(
99            'Successfully added COURSE1.' in self.browser.contents)
100        return
Note: See TracBrowser for help on using the repository browser.