source: main/waeup.aaua/trunk/src/waeup/aaua/students/tests/test_browser.py @ 10157

Last change on this file since 10157 was 10157, checked in by Henrik Bettermann, 11 years ago

In AAUA we have special postgrad students like in Uniben.

  • Property svn:keywords set to Id
File size: 4.8 KB
Line 
1## $Id: test_browser.py 10157 2013-05-07 19:12:39Z 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.component.hooks import setSite, clearSite
24from zope.component import getUtility, createObject
25from zope.interface import verify
26from waeup.kofa.app import University
27from waeup.kofa.students.tests.test_browser import (
28    StudentsFullSetup, SAMPLE_IMAGE)
29from waeup.kofa.students.accommodation import BedTicket
30from waeup.kofa.testing import FunctionalTestCase
31from waeup.kofa.interfaces import (
32    IExtFileStore, IFileStoreNameChooser)
33from waeup.kofa.students.interfaces import IStudentsUtils
34from waeup.aaua.testing import FunctionalLayer
35
36
37class StudentProcessorTest(FunctionalTestCase):
38    """Perform some batching tests.
39    """
40
41    layer = FunctionalLayer
42
43    def setUp(self):
44        super(StudentProcessorTest, self).setUp()
45        # Setup a sample site for each test
46        app = University()
47        self.dc_root = tempfile.mkdtemp()
48        app['datacenter'].setStoragePath(self.dc_root)
49
50        # Prepopulate the ZODB...
51        self.getRootFolder()['app'] = app
52        # we add the site immediately after creation to the
53        # ZODB. Catalogs and other local utilities are not setup
54        # before that step.
55        self.app = self.getRootFolder()['app']
56        # Set site here. Some of the following setup code might need
57        # to access grok.getSite() and should get our new app then
58        setSite(app)
59
60
61    def tearDown(self):
62        super(StudentProcessorTest, self).tearDown()
63        shutil.rmtree(self.workdir)
64        shutil.rmtree(self.dc_root)
65        clearSite()
66        return
67
68class StudentUITests(StudentsFullSetup):
69    """Tests for customized student class views and pages
70    """
71
72    layer = FunctionalLayer
73
74    def setUp(self):
75        super(StudentUITests, self).setUp()
76
77        bedticket = BedTicket()
78        bedticket.booking_session = 2004
79        bedticket.bed_type = u'any bed type'
80        bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
81        bedticket.bed_coordinates = u'My bed coordinates'
82        self.student['accommodation'].addBedTicket(bedticket)
83
84    def test_student_start_clearance(self):
85        self.browser.open(self.login_path)
86        self.browser.getControl(name="form.login").value = self.student_id
87        self.browser.getControl(name="form.password").value = 'spwd'
88        self.browser.getControl("Login").click()
89
90        IWorkflowInfo(self.student).fireTransition('admit')
91        self.browser.open(self.student_path + '/change_portrait')
92        image = open(SAMPLE_IMAGE, 'rb')
93        ctrl = self.browser.getControl(name='passportuploadedit')
94        file_ctrl = ctrl.mech_control
95        file_ctrl.add_file(image, filename='my_photo.jpg')
96        self.browser.getControl(
97            name='upload_passportuploadedit').click()
98        self.browser.open(self.student_path + '/start_clearance')
99        # In AAUA the students can just start clearance without entering
100        # an activation code.
101        self.browser.getControl("Start clearance now").click()
102        self.assertMatches('...Clearance process has been started...',
103                           self.browser.contents)
104
105    def test_next_session_allowed(self):
106        # Let's see if next_session_allowed works as expected
107        # A, ug_ft, 100
108        IWorkflowState(self.student).setState('returning')
109        self.assertTrue(self.student['studycourse'].next_session_allowed)
110        # Uniben special PG programmes have the same workflow
111        # as UG students
112        self.certificate.study_mode = 'special_pg'
113        self.assertTrue(self.student['studycourse'].next_session_allowed)
114        IWorkflowState(self.student).setState('school fee paid')
115        self.assertFalse(self.student['studycourse'].next_session_allowed)
116        # Now we convert the certificate into a 'regular
117        # postgraduate certificate ...
118        self.certificate.study_mode = 'pg_xx'
119        # ... and voila next session registration is allowed
120        self.assertTrue(self.student['studycourse'].next_session_allowed)
Note: See TracBrowser for help on using the repository browser.