source: main/kofacustom.edocons/trunk/src/kofacustom/edocons/students/tests/test_browser.py @ 17414

Last change on this file since 17414 was 17406, checked in by Henrik Bettermann, 17 months ago

Add fields and change field names.

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1## $Id: test_browser.py 17406 2023-05-09 15:19:08Z 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.edocons.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
48class 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
71    def test_transcripts(self):
72        studylevel = createObject(u'waeup.StudentStudyLevel')
73        studylevel.level = 100
74        studylevel.level_session = 2005
75        self.student['studycourse'].entry_mode = 'ug_ft'
76        self.student['studycourse'].addStudentStudyLevel(
77            self.certificate, studylevel)
78        studylevel2 = createObject(u'waeup.StudentStudyLevel')
79        studylevel2.level = 110
80        studylevel2.level_session = 2006
81        self.student['studycourse'].addStudentStudyLevel(
82            self.certificate, studylevel2)
83        # Add second course (COURSE has been added automatically)
84        courseticket = createObject('waeup.CourseTicket')
85        courseticket.code = 'ANYCODE'
86        courseticket.title = u'Any TITLE'
87        courseticket.credits = 13
88        courseticket.score = 66
89        courseticket.semester = 1
90        courseticket.attempted_number = 4
91        courseticket.dcode = u'ANYDCODE'
92        courseticket.fcode = u'ANYFCODE'
93        self.student['studycourse']['110']['COURSE2'] = courseticket
94        self.student['studycourse']['100']['COURSE1'].score = 55
95        self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 2.5)
96        self.assertEqual(self.student['studycourse']['110'].gpa_params_rectified[0], 3.0)
97        # Get transcript data
98        td = self.student['studycourse'].getTranscriptData()
99        self.assertEqual(td[0][0]['level_key'], '100')
100        self.assertEqual(td[0][0]['sgpa'], 2.5)
101        self.assertEqual(td[0][0]['level'].level, 100)
102        self.assertEqual(td[0][0]['level'].level_session, 2005)
103        self.assertEqual(td[0][0]['tickets_1'][0].code, 'COURSE1')
104        self.assertEqual(td[0][1]['level_key'], '110')
105        self.assertEqual(td[0][1]['sgpa'], 3.0)
106        self.assertEqual(td[0][1]['level'].level, 110)
107        self.assertEqual(td[0][1]['level'].level_session, 2006)
108        self.assertEqual(td[0][1]['tickets_1'][0].code, 'ANYCODE')
109        self.assertEqual(td[1], 2.782608695652174)
110        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
111        self.browser.open(self.student_path + '/studycourse/transcript')
112        self.assertEqual(self.browser.headers['Status'], '200 Ok')
113        self.assertTrue('Transcript' in self.browser.contents)
114        # Officers can open the pdf transcript
115        self.browser.open(self.student_path + '/studycourse/transcript.pdf')
116        self.assertEqual(self.browser.headers['Status'], '200 Ok')
117        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
118        path = os.path.join(samples_dir(), 'transcript.pdf')
119        open(path, 'wb').write(self.browser.contents)
120        print "Sample PDF transcript.pdf written to %s" % path
121 
Note: See TracBrowser for help on using the repository browser.