Changeset 7057 for main/waeup.sirp


Ignore:
Timestamp:
9 Nov 2011, 12:34:48 (13 years ago)
Author:
Henrik Bettermann
Message:

Managers can relocate students if the bed's bed_type has changed.

Also fix assertion. Then we see that handle_bedticket_removed event handler does not work properly.

File:
1 edited

Legend:

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

    r7056 r7057  
    2727import cStringIO
    2828from datetime import datetime
     29import grok
     30from zope.event import notify
    2931from zope.component import createObject
    3032from zope.component.hooks import setSite, clearSite
     
    927929                           self.browser.contents)
    928930        # Bed has been allocated
    929         bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
    930         self.assertTrue(bed.owner == self.student_id)
     931        bed1 = self.app['hostels']['hall-1']['hall-1_A_101_A']
     932        self.assertTrue(bed1.owner == self.student_id)
    931933        # BedTicketAddPage is now blocked
    932934        self.browser.getLink("Book accommodation").click()
     
    940942        self.assertMatches('...regular_male_fr...', self.browser.contents)
    941943        self.assertMatches('...%s...' % pin, self.browser.contents)
    942         # Managers can relocate students
     944        # Managers can relocate students if the student's bed_type has changed
    943945        self.browser.getLink("Relocate student").click()
    944946        self.assertMatches(
     
    948950        self.assertMatches(
    949951            "...Hall 1, Block A, Room 101, Bed B...", self.browser.contents)
    950         bed1 = self.app['hostels']['hall-1']['hall-1_A_101_A']
    951952        self.assertTrue(bed1.owner == NOT_OCCUPIED)
    952953        bed2 = self.app['hostels']['hall-1']['hall-1_A_101_B']
     
    958959        payment = self.student['payments'][payment_id]
    959960        self.assertTrue(payment.p_item == u'regular_male_fr')
     961        # Managers can relocate students if the bed's bed_type has changed
     962        bed1.bed_type = u'regular_female_fr'
     963        bed2.bed_type = u'regular_male_reserved'
     964        notify(grok.ObjectModifiedEvent(bed1))
     965        notify(grok.ObjectModifiedEvent(bed2))
     966        self.browser.getLink("Relocate student").click()
     967        self.assertMatches(
     968            "...Student relocated and new bed booked...", self.browser.contents)
     969        self.assertMatches(
     970            "... Hall 1, Block A, Room 101, Bed A...", self.browser.contents)
     971        self.assertMatches(bed1.owner, self.student_id)
     972        self.assertMatches(bed2.owner, NOT_OCCUPIED)
    960973        # Managers can delete bed tickets
    961974        self.browser.open(self.acco_student_path)
     
    965978        self.browser.getControl("Remove selected", index=0).click()
    966979        self.assertMatches('...Successfully removed...', self.browser.contents)
    967         # The bed has been released properly by the event handler
    968         bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
    969         self.assertTrue(bed.owner == NOT_OCCUPIED)
     980        # The bed has been properly released by the event handler
     981        self.assertMatches(bed1.owner, NOT_OCCUPIED)
     982        self.assertMatches(bed2.owner, NOT_OCCUPIED)
    970983        return
    971984
Note: See TracChangeset for help on using the changeset viewer.