Ignore:
Timestamp:
14 Oct 2015, 09:34:30 (9 years ago)
Author:
Henrik Bettermann
Message:

Add some methods to release expired bed allocations. View
components have to be added in custom packages.

File:
1 edited

Legend:

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

    r13315 r13316  
    3535from waeup.kofa.hostels.interfaces import (
    3636    IHostelsContainer, IHostel, IBed)
     37from waeup.kofa.hostels.vocabularies import NOT_OCCUPIED
    3738from waeup.kofa.hostels.container import HostelsContainer
    3839from waeup.kofa.hostels.hostel import Hostel, Bed
     
    173174        clearSite()
    174175        shutil.rmtree(self.dc_root)
     176
     177class HostelsContainerTests(HostelsFullSetup):
     178
     179    layer = FunctionalLayer
     180
     181    def test_release_expired_allocations(self):
     182        cat = queryUtility(ICatalog, name='beds_catalog')
     183        bedticket = BedTicket()
     184        bedticket.booking_session = 2004
     185        bedticket.bed_coordinates = u'anything'
     186        self.student['accommodation'].addBedTicket(bedticket)
     187        self.app[
     188            'hostels']['hall-x']['hall_block_room_bed'].owner = self.student_id
     189        notify(grok.ObjectModifiedEvent(
     190            self.app['hostels']['hall-x']['hall_block_room_bed']))
     191        results = cat.searchResults(owner=(self.student_id, self.student_id))
     192        self.assertEqual(len(results), 1)
     193        released = self.app['hostels'].releaseExpiredAllocations(7)
     194        self.assertEqual(released, 0)
     195        delta = timedelta(days=10)
     196        bedticket.booking_date = datetime.utcnow() - delta
     197        released = self.app['hostels'].releaseExpiredAllocations(7)
     198        self.assertEqual(released, 1)
     199        results = cat.searchResults(owner=(self.student_id, self.student_id))
     200        self.assertEqual(len(results), 0)
     201        self.assertMatches(bedticket.display_coordinates,
     202            '-- booking expired (2015-10-14 08:35:38 UTC) --')
     203        self.assertEqual(
     204            self.app['hostels']['hall-x']['hall_block_room_bed'].owner,
     205            NOT_OCCUPIED)
     206        return
    175207
    176208class BedCatalogTests(HostelsFullSetup):
     
    330362        self.assertMatches(bedticket.bed_coordinates,
    331363          u' -- booking cancelled on <YYYY-MM-DD hh:mm:ss> UTC --')
    332         # The catalog was updated.
     364        # The catalog has been updated.
    333365        results = cat.searchResults(owner=(self.student_id, self.student_id))
    334366        assert len(results) == 0
Note: See TracChangeset for help on using the changeset viewer.