source: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py @ 13384

Last change on this file since 13384 was 13374, checked in by Henrik Bettermann, 10 years ago

Configure new payment categories. School fee amounts are now set via certificates not session configuration objects.

  • Property svn:keywords set to Id
File size: 27.3 KB
Line 
1## $Id: test_browser.py 13374 2015-11-01 14:11:52Z 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
21import pytz
22import grok
23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
24from datetime import datetime, timedelta, date
25from mechanize import LinkNotFoundError
26from hurry.workflow.interfaces import IWorkflowState
27from zope.component.hooks import setSite, clearSite
28from zope.component import getUtility, createObject, queryUtility
29from zope.catalog.interfaces import ICatalog
30from waeup.kofa.app import University
31from waeup.kofa.students.tests.test_browser import StudentsFullSetup
32from waeup.kofa.students.accommodation import BedTicket
33from waeup.kofa.testing import FunctionalTestCase
34from waeup.kofa.browser.tests.test_pdf import samples_dir
35from waeup.aaue.testing import FunctionalLayer
36
37SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
38
39
40class StudentProcessorTest(FunctionalTestCase):
41    """Perform some batching tests.
42    """
43
44    layer = FunctionalLayer
45
46    def setUp(self):
47        super(StudentProcessorTest, self).setUp()
48        # Setup a sample site for each test
49        app = University()
50        self.dc_root = tempfile.mkdtemp()
51        app['datacenter'].setStoragePath(self.dc_root)
52
53        # Prepopulate the ZODB...
54        self.getRootFolder()['app'] = app
55        # we add the site immediately after creation to the
56        # ZODB. Catalogs and other local utilities are not setup
57        # before that step.
58        self.app = self.getRootFolder()['app']
59        # Set site here. Some of the following setup code might need
60        # to access grok.getSite() and should get our new app then
61        setSite(app)
62
63
64    def tearDown(self):
65        super(StudentProcessorTest, self).tearDown()
66        shutil.rmtree(self.workdir)
67        shutil.rmtree(self.dc_root)
68        clearSite()
69        return
70
71class OfficerUITests(StudentsFullSetup):
72    # Tests for Student class views and pages
73
74    layer = FunctionalLayer
75
76    def test_gpa_calculation(self):
77        studylevel = createObject(u'waeup.StudentStudyLevel')
78        studylevel.level = 100
79        studylevel.level_session = 2005
80        self.student['studycourse'].entry_mode = 'ug_ft'
81        self.student['studycourse'].addStudentStudyLevel(
82            self.certificate, studylevel)
83        # First course has been added automatically.
84        # Set score.
85        studylevel['COURSE1'].score = 55
86        # GPA is 3.0.
87        self.assertEqual(studylevel.gpa_params[0], 3.0)
88        courseticket = createObject('waeup.CourseTicket')
89        courseticket.code = 'ANYCODE'
90        courseticket.title = u'Any TITLE'
91        courseticket.credits = 13
92        courseticket.score = 66
93        courseticket.semester = 1
94        courseticket.dcode = u'ANYDCODE'
95        courseticket.fcode = u'ANYFCODE'
96        studylevel['COURSE2'] = courseticket
97        # total credits
98        self.assertEqual(self.student['studycourse']['100'].gpa_params[1], 23)
99        # weigheted credits = 3 * 10 + 4 * 13
100        self.assertEqual(self.student['studycourse']['100'].gpa_params[2], 82.0)
101        # sgpa = 82 / 23
102        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.565)
103        return
104
105    def test_manage_payments(self):
106        # Add missing configuration data
107        self.app['configuration']['2004'].gown_fee = 150.0
108        self.app['configuration']['2004'].transfer_fee = 90.0
109        self.app['configuration']['2004'].booking_fee = 150.0
110        self.app['configuration']['2004'].maint_fee = 180.0
111        self.app['configuration']['2004'].late_fee = 80.0
112
113        # Managers can add online payment tickets
114        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
115        self.browser.open(self.payments_path)
116        self.browser.getLink("Add current session payment ticket").click()
117        self.browser.getControl(name="form.p_category").value = ['schoolfee']
118        self.browser.getControl("Create ticket").click()
119        self.assertMatches('...Wrong state...',
120                           self.browser.contents)
121        IWorkflowState(self.student).setState('cleared')
122        self.browser.open(self.payments_path + '/addop')
123        self.browser.getControl("Create ticket").click()
124        self.assertMatches('...Amount could not be determined...',
125                           self.browser.contents)
126        #self.browser.getControl(name="form.p_category").value = ['schoolfee']
127        # Accepotance fee must be paid first
128        #self.browser.getControl("Create ticket").click()
129        #self.assertMatches('...Please pay acceptance fee first...',
130        #                   self.browser.contents)
131        self.app['configuration']['2004'].clearance_fee = 666.0
132        self.browser.getControl(name="form.p_category").value = ['clearance']
133        self.browser.getControl("Create ticket").click()
134        ctrl = self.browser.getControl(name='val_id')
135        cpt_value = ctrl.options[0]
136        # School fee payment ticket can be added ...
137        self.student['studycourse'].certificate.school_fee_1 = 6666.0
138        self.student.nationality = u'NG'
139        self.browser.open(self.payments_path + '/addop')
140        self.browser.getControl(name="form.p_category").value = ['schoolfee']
141        self.browser.getControl("Create ticket").click()
142        self.assertMatches('...ticket created...',
143                           self.browser.contents)
144        # ... but not paid through the query_history page.
145        ctrl = self.browser.getControl(name='val_id')
146        sfpt_value = ctrl.options[1]
147        self.student['studycourse'].entry_session = 2013
148        self.browser.open(self.payments_path + '/' + sfpt_value)
149        self.browser.getLink("Query eTranzact History").click()
150        self.assertMatches('...alert-danger">Please pay acceptance fee first...',
151                           self.browser.contents)
152        # If clearance/acceptance fee is paid ...
153        self.student['payments'][cpt_value].approveStudentPayment()
154        self.browser.getLink("Query eTranzact History").click()
155        # ... query_history page is accessible.
156        self.assertMatches(
157            '...<h1 class="kofa-content-label">Requery eTranzact History</h1>...',
158            self.browser.contents)
159        # Managers can open school fee payment slip
160        self.browser.open(self.payments_path + '/' + sfpt_value)
161        self.browser.getLink("Download payment slip").click()
162        self.assertEqual(self.browser.headers['Status'], '200 Ok')
163        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
164        # If school fee ticket is paid, the student is automatically set to
165        # school fee paid...
166        ticket = self.student['payments'][sfpt_value].approveStudentPayment()
167        self.assertEqual(self.student.state, 'school fee paid')
168        # ... no further school fee ticket can be added.
169        self.browser.open(self.payments_path + '/addop')
170        self.browser.getControl(name="form.p_category").value = ['schoolfee']
171        self.browser.getControl("Create ticket").click()
172        self.assertMatches('...Wrong state...',
173                           self.browser.contents)
174        self.browser.open(self.payments_path + '/addop')
175        self.browser.getControl(name="form.p_category").value = ['late_registration']
176        self.browser.getControl("Create ticket").click()
177        self.assertMatches('...ticket created...',
178                           self.browser.contents)
179
180    def deactivated_test_for_instalment_payments(self):
181        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
182        self.browser.open(self.payments_path)
183        self.browser.open(self.payments_path + '/addop')
184        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
185        self.browser.getControl("Create ticket").click()
186        self.assertMatches('...ticket created...',
187                           self.browser.contents)
188        # We can't add the 2nd instalment ticket because the
189        # first one has not yet been approved.
190        self.browser.open(self.payments_path + '/addop')
191        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
192        self.browser.getControl("Create ticket").click()
193        self.assertMatches('...1st school fee instalment has not yet been paid...',
194                           self.browser.contents)
195        # Ok, then we approve the first instalment ...
196        self.browser.open(self.payments_path)
197        ctrl = self.browser.getControl(name='val_id')
198        p_id = ctrl.options[0]
199        self.browser.open(self.payments_path + '/' + p_id + '/approve')
200        # ... add the second instalment ...
201        self.browser.open(self.payments_path + '/addop')
202        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
203        self.browser.getControl("Create ticket").click()
204        self.assertMatches('...ticket created...',
205                           self.browser.contents)
206        # ... approve the second instalment ...
207        ctrl = self.browser.getControl(name='val_id')
208        p_id = ctrl.options[1]
209        self.browser.open(self.payments_path + '/' + p_id + '/approve')
210        # ... and finally add the 1st instalment for the next session
211        # provided that student is returning.
212        IWorkflowState(self.student).setState('returning')
213        self.browser.open(self.payments_path + '/addop')
214        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
215        self.browser.getControl("Create ticket").click()
216        self.assertMatches('...Session configuration object is not...',
217                           self.browser.contents)
218        # Uups, we forgot to add a session configuration for next session
219        configuration = createObject('waeup.SessionConfiguration')
220        configuration.academic_session = 2005
221        self.app['configuration'].addSessionConfiguration(configuration)
222        self.app['configuration']['2005'].school_base = 7777.0
223        self.browser.open(self.payments_path + '/addop')
224        self.browser.getControl(name="form.p_category").value = ['schoolfee_1']
225        self.browser.getControl("Create ticket").click()
226        self.assertMatches('...ticket created...',
227                           self.browser.contents)
228        # If the session configuration doesn't exist an error message will
229        # be shown. No other requirement is being checked.
230        del self.app['configuration']['2004']
231        self.browser.open(self.payments_path)
232        self.browser.getLink("Add current session payment ticket").click()
233        self.browser.getControl("Create ticket").click()
234        self.assertMatches('...Session configuration object is not...',
235                           self.browser.contents)
236
237    def test_manage_payments_bypass_ac_creation(self):
238        self.student['studycourse'].certificate.school_fee_1 = 6666.0
239        self.student.nationality = u'NG'
240        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
241        self.browser.open(self.payments_path)
242        IWorkflowState(self.student).setState('cleared')
243        self.browser.getLink("Add current session payment ticket").click()
244        self.browser.getControl(name="form.p_category").value = ['schoolfee']
245        self.browser.getControl("Create ticket").click()
246        ctrl = self.browser.getControl(name='val_id')
247        value = ctrl.options[0]
248        self.browser.getLink(value).click()
249        payment_url = self.browser.url
250        logfile = os.path.join(
251            self.app['datacenter'].storage, 'logs', 'students.log')
252        # The ticket can be found in the payments_catalog
253        cat = queryUtility(ICatalog, name='payments_catalog')
254        results = list(cat.searchResults(p_state=('unpaid', 'unpaid')))
255        self.assertTrue(len(results), 1)
256        self.assertTrue(results[0] is self.student['payments'][value])
257        # Managers can approve the payment
258        self.browser.open(payment_url)
259        self.browser.getLink("Approve payment").click()
260        self.assertMatches('...Payment approved...',
261                          self.browser.contents)
262        # Approval is logged in students.log ...
263        logcontent = open(logfile).read()
264        self.assertTrue(
265            'zope.mgr - students.browser.OnlinePaymentApproveView '
266            '- E1000000 - schoolfee payment approved'
267            in logcontent)
268        # ... and in payments.log
269        logfile = os.path.join(
270            self.app['datacenter'].storage, 'logs', 'payments.log')
271        logcontent = open(logfile).read()
272        self.assertTrue(
273            '"zope.mgr",E1000000,%s,schoolfee,6666.0,AP,,,,,,\n' % value
274            in logcontent)
275        # Student is in state school fee paid, no activation
276        # code was necessary.
277        self.assertEqual(self.student.state, 'school fee paid')
278        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
279        return
280
281class StudentUITests(StudentsFullSetup):
282    """Tests for customized student class views and pages
283    """
284
285    layer = FunctionalLayer
286
287    def setUp(self):
288        super(StudentUITests, self).setUp()
289
290        bedticket = BedTicket()
291        bedticket.booking_session = 2004
292        bedticket.bed_type = u'any bed type'
293        bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
294        bedticket.bed_coordinates = u'My bed coordinates'
295        self.student['accommodation'].addBedTicket(bedticket)
296
297    def test_student_payments(self):
298        # Login
299        IWorkflowState(self.student).setState('returning')
300        self.browser.open(self.login_path)
301        self.browser.getControl(name="form.login").value = self.student_id
302        self.browser.getControl(name="form.password").value = 'spwd'
303        self.browser.getControl("Login").click()
304        self.browser.open(self.student_path + '/payments')
305        self.assertTrue(
306          'Add current session payment ticket' in self.browser.contents)
307        self.assertFalse(
308          'Add previous session payment ticket' in self.browser.contents)
309        return
310
311    def test_late_registration(self):
312        # Login
313        delta = timedelta(days=10)
314        self.app['configuration'][
315            '2004'].coursereg_deadline = datetime.now(pytz.utc) - delta
316        IWorkflowState(self.student).setState('school fee paid')
317        # Current session is 2004. Here we test course registration for
318        # returning students.
319        self.student['studycourse'].entry_session = 2003
320        self.browser.open(self.login_path)
321        self.browser.getControl(name="form.login").value = self.student_id
322        self.browser.getControl(name="form.password").value = 'spwd'
323        self.browser.getControl("Login").click()
324        self.browser.open(self.payments_path)
325        self.browser.open(self.payments_path + '/addop')
326        self.browser.getControl(name="form.p_category").value = ['late_registration']
327        self.browser.getControl("Create ticket").click()
328        self.assertMatches('...ticket created...',
329                           self.browser.contents)
330        self.browser.open(self.payments_path)
331        ctrl = self.browser.getControl(name='val_id')
332        value = ctrl.options[0]
333        self.browser.getLink("Study Course").click()
334        self.browser.getLink("Add course list").click()
335        self.assertMatches('...Add current level 100 (Year 1)...',
336                           self.browser.contents)
337        self.browser.getControl("Create course list now").click()
338        self.browser.getLink("100").click()
339        self.browser.getLink("Edit course list").click()
340        self.browser.getControl("Register course list").click()
341        self.assertTrue('Course registration has ended. Please pay' in self.browser.contents)
342        self.student['payments'][value].approve()
343        self.browser.getControl("Register course list").click()
344        self.assertTrue('Course list has been registered' in self.browser.contents)
345        self.assertEqual(self.student.state, 'courses registered')
346        # Reset student and check if fresh students are always allowed to
347        # register courses.
348        self.student['studycourse'].entry_session = 2004
349        del self.student['payments'][value]
350        IWorkflowState(self.student).setState('school fee paid')
351        self.browser.open(self.studycourse_path + '/100/edit')
352        self.browser.getControl("Register course list").click()
353        self.assertTrue('Course list has been registered' in self.browser.contents)
354        return
355
356
357    def deactivated_test_student_course_registration(self):
358        # Add more courses
359        self.course2 = createObject('waeup.Course')
360        self.course2.code = 'COURSE2'
361        self.course2.semester = 2
362        self.course2.credits = 10
363        self.course2.passmark = 40
364        self.app['faculties']['fac1']['dep1'].courses.addCourse(
365            self.course2)
366        self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
367            self.course2, level=100)
368        self.course3 = createObject('waeup.Course')
369        self.course3.code = 'COURSE3'
370        self.course3.semester = 3
371        self.course3.credits = 10
372        self.course3.passmark = 40
373        self.app['faculties']['fac1']['dep1'].courses.addCourse(
374            self.course3)
375        self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
376            self.course3, level=100)
377
378        # Login as student
379        self.browser.open(self.login_path)
380        IWorkflowState(self.student).setState('school fee paid')
381        self.browser.open(self.login_path)
382        self.browser.getControl(name="form.login").value = self.student_id
383        self.browser.getControl(name="form.password").value = 'spwd'
384        self.browser.getControl("Login").click()
385        # Students can add the current study level
386        self.browser.getLink("Study Course").click()
387        self.browser.getLink("Add course list").click()
388        self.assertMatches('...Add current level 100 (Year 1)...',
389                           self.browser.contents)
390        self.browser.getControl("Create course list now").click()
391        # Student has not paid second instalment, therefore a level
392        # with two course ticket was created (semester 1 and combined)
393        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 2)
394        self.browser.getLink("100").click()
395        self.browser.getLink("Edit course list").click()
396        self.browser.getControl("Add course ticket").click()
397        # Student can't add second semester course
398        self.assertTrue('<option value="COURSE1">' in self.browser.contents)
399        self.assertTrue('<option value="COURSE3">' in self.browser.contents)
400        self.assertFalse('<option value="COURSE2">' in self.browser.contents)
401
402        # Let's remove level and see what happens after 2nd instalment payment
403        del(self.student['studycourse']['100'])
404        payment2 = createObject('waeup.StudentOnlinePayment')
405        payment2.p_category = u'schoolfee_2'
406        payment2.p_session = self.student.current_session
407        self.student['payments']['anykey'] = payment2
408        self.browser.open(self.studycourse_path)
409        self.browser.getLink("Add course list").click()
410        self.browser.getControl("Create course list now").click()
411        # Still only 2 tickets have been created since payment ticket
412        # was not paid
413        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 2)
414        payment2.p_state = u'paid'
415        del(self.student['studycourse']['100'])
416        self.browser.open(self.studycourse_path)
417        self.browser.getLink("Add course list").click()
418        self.browser.getControl("Create course list now").click()
419        # Now 2nd semester course has been added
420        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 3)
421        # Student can add second semester course
422        self.browser.getLink("100").click()
423        self.browser.getLink("Edit course list").click()
424        self.browser.getControl("Add course ticket").click()
425        self.assertTrue('<option value="COURSE1">' in self.browser.contents)
426        self.assertTrue('<option value="COURSE2">' in self.browser.contents)
427        self.assertTrue('<option value="COURSE3">' in self.browser.contents)
428        return
429
430    def test_set_matric_number(self):
431        # Login as student
432        self.browser.open(self.login_path)
433        IWorkflowState(self.student).setState('school fee paid')
434        self.browser.open(self.login_path)
435        self.browser.getControl(name="form.login").value = self.student_id
436        self.browser.getControl(name="form.password").value = 'spwd'
437        self.browser.getControl("Login").click()
438        self.assertRaises(
439            LinkNotFoundError,
440            self.browser.getLink, 'Get Matriculation Number')
441        self.student.matric_number = None
442        site = grok.getSite()
443        site['configuration'].next_matric_integer = 1
444        self.student['studycourse'].certificate.study_mode = 'ug_pt'
445        self.browser.open(self.student_path)
446        self.assertRaises(
447            LinkNotFoundError,
448            self.browser.getLink, 'Download matriculation number slip')
449        self.browser.getLink("Get Matriculation Number").click()
450        self.assertTrue('Matriculation number PTP/fac1/dep1/04/00001 assigned.'
451            in self.browser.contents)
452        self.assertEqual(self.student.matric_number, 'PTP/fac1/dep1/04/00001')
453        self.assertRaises(
454            LinkNotFoundError,
455            self.browser.getLink, 'Get Matriculation Number')
456        # Setting matric number is logged.
457        logfile = os.path.join(
458            self.app['datacenter'].storage, 'logs', 'students.log')
459        logcontent = open(logfile).read()
460        self.assertTrue('E1000000 - waeup.aaue.students.browser.StudentGetMatricNumberPage - '
461                        'E1000000 - PTP/fac1/dep1/04/00001 assigned' in logcontent)
462        # Matric Number Slip can be downloaded
463        self.browser.getLink("Download matriculation number slip").click()
464        self.assertEqual(self.browser.headers['Status'], '200 Ok')
465        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
466        path = os.path.join(samples_dir(), 'matric_number_slip.pdf')
467        open(path, 'wb').write(self.browser.contents)
468        print "Sample PDF matric_number_slip.pdf written to %s" % path
469        return
470
471    def test_student_course_registration(self):
472        IWorkflowState(self.student).setState('school fee paid')
473        self.browser.open(self.login_path)
474        self.browser.getControl(name="form.login").value = self.student_id
475        self.browser.getControl(name="form.password").value = 'spwd'
476        self.browser.getControl("Login").click()
477        # Now students can add the current study level
478        self.browser.getLink("Study Course").click()
479        self.browser.getLink("Add course list").click()
480        self.assertMatches('...Add current level 100 (Year 1)...',
481                           self.browser.contents)
482        self.browser.getControl("Create course list now").click()
483        # Students can't open the customized pdf course registration slip
484        self.browser.open(
485            self.student_path + '/studycourse/100/course_registration_slip.pdf')
486        self.assertTrue('Forbidden' in self.browser.contents)
487        # They can open slips from the previous session ...
488        self.student['studycourse'].current_level = 200
489        self.browser.open(self.student_path + '/studycourse/100')
490        self.browser.getLink("Download course registration slip").click()
491        self.assertEqual(self.browser.headers['Status'], '200 Ok')
492        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
493        # or if they have registered their course list
494        self.student['studycourse'].current_level = 200
495        IWorkflowState(self.student).setState('courses registered')
496        self.browser.open(self.student_path + '/studycourse/100')
497        self.browser.getLink("Download course registration slip").click()
498        self.assertEqual(self.browser.headers['Status'], '200 Ok')
499        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
500
501    def test_student_clearance(self):
502        # Student cant login if their password is not set
503        IWorkflowInfo(self.student).fireTransition('admit')
504        self.browser.open(self.login_path)
505        self.browser.getControl(name="form.login").value = self.student_id
506        self.browser.getControl(name="form.password").value = 'spwd'
507        self.browser.getControl("Login").click()
508        self.assertMatches(
509            '...You logged in...', self.browser.contents)
510        # Admitted student can upload a passport picture
511        self.browser.open(self.student_path + '/change_portrait')
512        ctrl = self.browser.getControl(name='passportuploadedit')
513        file_obj = open(SAMPLE_IMAGE, 'rb')
514        file_ctrl = ctrl.mech_control
515        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
516        self.browser.getControl(
517            name='upload_passportuploadedit').click()
518        self.assertTrue(
519            'src="http://localhost/app/students/E1000000/passport.jpg"'
520            in self.browser.contents)
521        # Student is redirected to the personal data form because
522        # personal data form is not properly filled.
523        self.browser.open(self.student_path + '/start_clearance')
524        self.assertMatches('...Personal data form is not properly filled...',
525                           self.browser.contents)
526        self.assertEqual(self.browser.url, self.student_path + '/edit_personal')
527        self.student.father_name = u'Rudolf'
528        self.browser.open(self.student_path + '/start_clearance')
529        self.assertMatches('...<h1 class="kofa-content-label">Start clearance</h1>...',
530                   self.browser.contents)
531
532    def test_student_accommodation(self):
533        del self.student['accommodation']['2004']
534        # Login
535        self.browser.open(self.login_path)
536        self.browser.getControl(name="form.login").value = self.student_id
537        self.browser.getControl(name="form.password").value = 'spwd'
538        self.browser.getControl("Login").click()
539        # Students can book accommodation without AC ...
540        self.browser.open(self.acco_path)
541        IWorkflowInfo(self.student).fireTransition('admit')
542        self.browser.getLink("Book accommodation").click()
543        self.assertFalse('Activation Code:' in self.browser.contents)
544        self.browser.getControl("Create bed ticket").click()
545        # Bed is randomly selected but, since there is only
546        # one bed for this student, we know that
547        self.assertEqual(self.student['accommodation']['2004'].bed_coordinates,
548            'Hall 1, Block A, Room 101, Bed A (regular_male_fr)')
549        # Only the hall name is displayed
550        self.assertEqual(self.student['accommodation']['2004'].display_coordinates,
551            'Hall 1')
552        self.assertFalse('Hall 1, Block A, Room 101, Bed A'
553            in self.browser.contents)
554        self.assertTrue('<td>Hall 1</td>'
555            in self.browser.contents)
556        return
Note: See TracBrowser for help on using the repository browser.