Changeset 3540 in products


Ignore:
Timestamp:
Sep 10, 2012 9:59:31 AM (8 years ago)
Author:
potar
Message:

fixed tests (extra info: http://codereview.corp.quintagroup.com/171241/show)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.portlet.collection/trunk/quintagroup/portlet/collection/tests/test_portlet.py

    r2755 r3540  
    187187        # to make sure they work 
    188188 
     189        def reset_memoize(inst): 
     190            # Decorator memoize adds attribute ('_memojito_') to class instance. 
     191            # It has cached function and their values so it should be deleted  
     192            # for testing. 
     193            # Extra info: http://codereview.corp.quintagroup.com/171241/show 
     194            if hasattr(inst, '_memojito_'): 
     195                delattr(inst, '_memojito_') 
     196    
    189197        # set up our portlet renderer 
    190198        mapping = PortletAssignmentMapping() 
     
    202210        # collection with no criteria -- should return empty list, without error 
    203211        self.assertEqual(len(collectionrenderer.results()), 0) 
     212        reset_memoize(collectionrenderer) 
    204213 
    205214        # let's make sure the results aren't being memoized 
     
    212221        self.folder.collection.queryCatalog = mark_collection_called 
    213222        collectionrenderer.results() 
     223        reset_memoize(collectionrenderer) 
    214224        self.folder.collection.queryCatalog = old_func 
    215225        self.failUnless(collection_was_called) 
     
    219229        crit.setValue('Folder') 
    220230        self.assertEqual(len(collectionrenderer.results()), 1) 
     231        reset_memoize(collectionrenderer) 
    221232 
    222233        # collection with multiple criteria -- should behave similarly 
     
    228239        self.folder.collection.setSortCriterion('modified', False) 
    229240        self.assertEqual(len(collectionrenderer.results()), 1) 
     241        reset_memoize(collectionrenderer) 
    230242 
    231243        # same criteria, now with limit set to 2 -- should return 2 (random) folders 
    232244        collectionrenderer.data.limit = 2 
    233245        self.assertEqual(len(collectionrenderer.results()), 2) 
     246        reset_memoize(collectionrenderer) 
    234247 
    235248        # make sure there's no error if the limit is greater than the # of results found 
    236249        collectionrenderer.data.limit = 10 
    237250        self.failUnless(len(collectionrenderer.results()) >= 6) 
     251        reset_memoize(collectionrenderer) 
    238252 
    239253 
Note: See TracChangeset for help on using the changeset viewer.