Changeset 6433


Ignore:
Timestamp:
20 Jun 2011, 16:54:45 (13 years ago)
Author:
uli
Message:

Add real catalog tests.

Fix test setup: setSite() must be called before ACs are added or they
are not catalogued. That should be fixed in other tests as well.

File:
1 edited

Legend:

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

    r6431 r6433  
    4949        self.getRootFolder()['app'] = app
    5050        self.app = self.getRootFolder()['app']
     51        setSite(self.app)
    5152
    5253        # Create batch
     
    6263        self.ac3 = batch.getAccessCode('APP-1-33333333')
    6364
    64         setSite(self.app)
     65
    6566        return
    6667
     
    7475        cat = queryUtility(ICatalog, name='accesscodes_catalog')
    7576        assert cat is not None
     77
     78    def test_search_by_code(self):
     79        # We can find a certain code
     80        cat = queryUtility(ICatalog, name='accesscodes_catalog')
     81        results = cat.searchResults(code=('APP-1-11111111', 'APP-1-11111111'))
     82        results = [x for x in results] # Turn results generator into list
     83        assert len(results) == 1
     84        assert results[0] is self.ac1
     85
     86    def test_search_code_not_existent(self):
     87        # Not existent codes will not be found
     88        cat = queryUtility(ICatalog, name='accesscodes_catalog')
     89        results = cat.searchResults(code=('APP-1-blah', 'APP-1-blah'))
     90        results = [x for x in results] # Turn results generator into list
     91        assert len(results) == 0
Note: See TracChangeset for help on using the changeset viewer.