Ignore:
Timestamp:
13 Feb 2012, 13:35:39 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test for reindexing the payments_catalog.

File:
1 edited

Legend:

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

    r7633 r7637  
    169169
    170170    def test_get_catalog(self):
    171         # We can get an students catalog if we wish
     171        # We can get a students catalog if we wish
    172172        cat = queryUtility(ICatalog, name='payments_catalog')
    173173        assert cat is not None
     
    217217        assert results[0] is self.app['students'][self.student_id][
    218218            'payments']['p1234567890']
     219
     220    def test_reindex_payments(self):
     221        cat = queryUtility(ICatalog, name='payments_catalog')
     222        results = cat.searchResults(p_state=('failed','failed'))
     223        assert len(results) == 0
     224        results = cat.searchResults(p_state=('paid','paid'))
     225        assert len(results) == 1
     226        results = [x for x in results] # Turn results generator into list
     227        assert results[0] is self.app['students'][self.student_id][
     228            'payments']['p1234567890']
     229        results[0].p_state = 'failed'
     230        # Since we did not fire an ObjectModifiedEvent the catalog remained
     231        # unchanged
     232        results = cat.searchResults(p_state=('paid','paid'))
     233        assert len(results) == 1
     234        # Reindexing the catalog will lead to correct search results
     235        #reindexPayments()
     236        cat.clear() # The test works with and without clearing the catalog
     237        cat.updateIndexes()
     238        results = cat.searchResults(p_state=('paid','paid'))
     239        assert len(results) == 0
     240        results = cat.searchResults(p_state=('failed','failed'))
     241        assert len(results) == 1
     242        results = [x for x in results] # Turn results generator into list
     243        assert len(results) == 1
     244        assert results[0] is self.app['students'][self.student_id][
     245            'payments']['p1234567890']
Note: See TracChangeset for help on using the changeset viewer.