Ignore:
Timestamp:
30 Nov 2014, 09:12:44 (10 years ago)
Author:
Henrik Bettermann
Message:

Add event subscriber handle_product_removed which ensures that also referrers to customer application objects are removed when a product is deleted.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py

    r12094 r12095  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
     18import os
    1819import grok
    1920import shutil
     
    167168        assert results[0] is self.customer['applications'][self.application_id]
    168169        assert results[0].product is self.product
     170
     171    def test_product_removal(self):
     172        # This test does not only test catalog components, it also ensures
     173        # that the product attribute of an application is cleared
     174        # but the last_product_id is not.
     175        del self.app['products'][self.product_id]
     176        self.assertTrue(self.application.product is None)
     177        self.assertEqual(self.application.last_product_id, 'SAM')
     178        cat = queryUtility(ICatalog, name='applications_catalog')
     179        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
     180        results = [x for x in results]
     181        assert len(results) == 1
     182        assert results[0] is self.customer['applications'][self.application_id]
     183        assert results[0].product is None
     184        # Product removal is being logged in customers.log
     185        logfile = os.path.join(
     186            self.app['datacenter'].storage, 'logs', 'customers.log')
     187        logcontent = open(logfile).read()
     188        self.assertTrue(
     189            'INFO - system - ObjectRemovedEvent - K1000000 - a101 - removed: product\n'
     190            in logcontent)
     191
Note: See TracChangeset for help on using the changeset viewer.