Ignore:
Timestamp:
7 Nov 2011, 09:42:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Add tests for student accommodation booking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7015 r7017  
    751751
    752752    def test_student_payments(self):
    753         # Set up SessionConfiguration object
     753        # Login
    754754        self.browser.open(self.login_path)
    755755        self.browser.getControl(name="form.login").value = self.student_id
     
    915915
    916916    def test_student_accommodation(self):
    917         return
     917        # Login
     918        self.browser.open(self.login_path)
     919        self.browser.getControl(name="form.login").value = self.student_id
     920        self.browser.getControl(name="form.password").value = 'spwd'
     921        self.browser.getControl("Login").click()
     922
     923        # Students can add online booking fee payment tickets and open the
     924        # callback view (see test_manage_payments)
     925        self.browser.getLink("Payments").click()
     926        self.browser.getControl("Add online payment ticket").click()
     927        self.browser.getControl(name="form.p_category").value = ['bed_allocation']
     928        self.browser.getControl("Create ticket").click()
     929        ctrl = self.browser.getControl(name='val_id')
     930        value = ctrl.options[0]
     931        self.browser.getLink(value).click()
     932        self.browser.open(self.browser.url + '/callback')
     933        # The new HOS-0 pin has been created
     934        self.assertEqual(len(self.app['accesscodes']['HOS-0']),1)
     935        pin = self.app['accesscodes']['HOS-0'].keys()[0]
     936        ac = self.app['accesscodes']['HOS-0'][pin]
     937        ac.owner = self.student_id
     938        parts = pin.split('-')[1:]
     939        sfeseries, sfenumber = parts
     940        # Students can use HOS code and book a bed space with it
     941        self.browser.open(self.acco_student_path)
     942        self.browser.getLink("Book accommodation").click()
     943        self.assertMatches('...You are in the wrong...',
     944                           self.browser.contents)
     945        IWorkflowInfo(self.student).fireTransition('admit')
     946        self.browser.getLink("Book accommodation").click()
     947        self.assertMatches('...Activation Code:...',
     948                           self.browser.contents)
     949        self.browser.getControl(name="ac_series").value = sfeseries
     950        self.browser.getControl(name="ac_number").value = sfenumber
     951        self.browser.getControl("Create bed ticket").click()
     952        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
     953                           self.browser.contents)
     954        # Bed has been allocated
     955        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
     956        self.assertTrue(bed.owner == self.student_id)
     957        # BedTicketAddPage is now blocked
     958        self.browser.getLink("Book accommodation").click()
     959        self.assertMatches('...You already booked a bed space...',
     960            self.browser.contents)
     961        # The bed ticket displays the data correctly
     962        self.browser.open(self.acco_student_path + '/2004')
     963        self.assertMatches('...Hall 1, Block A, Room 101, Bed A...',
     964                           self.browser.contents)
     965        self.assertMatches('...2004/2005...', self.browser.contents)
     966        self.assertMatches('...regular_male_fr...', self.browser.contents)
     967        self.assertMatches('...%s...' % pin, self.browser.contents)
     968        # Students can't relocate themselves
     969        self.assertFalse('Relocate' in self.browser.contents)
     970        relocate_path = self.acco_student_path + '/2004/relocate'
     971        self.assertRaises(
     972            Unauthorized, self.browser.open, relocate_path)
     973        # Students can't the Remove button and check boxes
     974        self.browser.open(self.acco_student_path)
     975        self.assertFalse('Remove' in self.browser.contents)
     976        self.assertFalse('val_id' in self.browser.contents)
     977        return
Note: See TracChangeset for help on using the changeset viewer.