Changeset 7045


Ignore:
Timestamp:
8 Nov 2011, 22:18:28 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test for bed release.

File:
1 edited

Legend:

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

    r7003 r7045  
    3434from waeup.sirp.hostels.hostel import Hostel, Bed
    3535from waeup.sirp.testing import (FunctionalLayer, FunctionalTestCase)
     36from waeup.sirp.students.student import Student
     37from waeup.sirp.students.accommodation import BedTicket
    3638
    3739class HostelsContainerTestCase(FunctionalTestCase):
     
    9597        setSite(app)
    9698
     99        # Add student with subobjects
     100        student = Student()
     101        student.fullname = u'Anna Tester'
     102        student.reg_number = u'123'
     103        student.matric_number = u'234'
     104        student.sex = u'f'
     105        self.app['students'].addStudent(student)
     106        self.student_id = student.student_id
     107        self.student = self.app['students'][self.student_id]
     108        self.student['studycourse'].current_session = 2004
     109        self.student['studycourse'].entry_session = 2004
     110
     111        # Set accommodation_session
     112        self.app['configuration'].accommodation_session = 2004
     113
    97114        # Create a hostel
    98115        hostel = Hostel()
     
    126143
    127144    def test_get_catalog(self):
    128         # We can get an students catalog if we wish
     145        # We can get a beds catalog if we wish
    129146        cat = queryUtility(ICatalog, name='beds_catalog')
    130147        assert cat is not None
     
    244261            'hall-1_A_101_D'].bed_type == 'regular_female_all'
    245262        self.assertFalse(expected in self.browser.contents)
     263        # Release bed which has previously been booked
     264        bedticket = BedTicket()
     265        bedticket.ticket_id = u'2004'
     266        bedticket.bed_coordinates = u'anything'
     267        self.student['accommodation'].addBedTicket(bedticket)
     268        self.app['hostels']['hall-1']['hall-1_A_101_D'].owner = self.student_id
     269        self.browser.open(self.container_path + '/hall-1/manage')
     270        ctrl = self.browser.getControl(name='val_id')
     271        ctrl.getControl(value='hall-1_A_101_D').selected = True
     272        self.browser.getControl("Release selected beds", index=0).click()
     273        self.assertMatches(
     274          '...Successfully released beds: hall-1_A_101_D (%s)...' % self.student_id,
     275          self.browser.contents)
     276        self.assertMatches(bedticket.bed_coordinates,
     277          u' -- booking cancelled on <YYYY-MM-DD hh:mm:ss> --')
    246278        # Remove entire hostel
    247279        self.browser.open(self.manage_container_path)
Note: See TracChangeset for help on using the changeset viewer.