Ignore:
Timestamp:
31 Oct 2011, 05:00:21 (13 years ago)
Author:
Henrik Bettermann
Message:

Add beds_catalog.

File:
1 edited

Legend:

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

    r6970 r6972  
    2323from zope.testbrowser.testing import Browser
    2424from zope.security.interfaces import Unauthorized
     25from zope.catalog.interfaces import ICatalog
     26from zope.component import queryUtility
    2527from waeup.sirp.app import University
    2628from waeup.sirp.hostels.interfaces import (
     
    9092        setSite(app)
    9193
     94        # Create a hostel
     95        hostel = Hostel()
     96        hostel.hostel_id = u'hall_x'
     97        self.app['hostels'][hostel.hostel_id] = hostel
     98
     99        # Create a bed
     100        bed = Bed()
     101        bed.bed_id = u'xyz'
     102        bed.bed_number = 1
     103        bed.bed_type = u'abc'
     104        self.app['hostels'][hostel.hostel_id][bed.bed_id] = bed
     105
    92106        self.container_path = 'http://localhost/app/hostels'
    93107        self.manage_container_path = self.container_path + '/@@manage'
     
    103117        clearSite()
    104118        shutil.rmtree(self.dc_root)
     119
     120class BedCatalogTests(HostelsFullSetup):
     121
     122    layer = FunctionalLayer
     123
     124    def test_get_catalog(self):
     125        # We can get an students catalog if we wish
     126        cat = queryUtility(ICatalog, name='beds_catalog')
     127        assert cat is not None
     128
     129    def test_search_by_type(self):
     130        # We can find a certain bed
     131        cat = queryUtility(ICatalog, name='beds_catalog')
     132        results = cat.searchResults(bed_type=('abc', 'abc'))
     133        results = [x for x in results] # Turn results generator into list
     134        assert len(results) == 1
     135        assert results[0] is self.app['hostels']['hall_x']['xyz']
    105136
    106137class HostelsUITests(HostelsFullSetup):
Note: See TracChangeset for help on using the changeset viewer.