Ignore:
Timestamp:
11 Dec 2014, 08:12:31 (10 years ago)
Author:
Henrik Bettermann
Message:

Fix handle_product_remove. The attribute is meanwhile called product_object.

Add handle_document_removed with test.

File:
1 edited

Legend:

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

    r12098 r12194  
    2424from zope.component import queryUtility, createObject
    2525from zope.component.hooks import setSite
     26from hurry.workflow.interfaces import IWorkflowState
    2627from waeup.ikoba.app import Company
     28from waeup.ikoba.interfaces import VERIFIED
    2729from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    2830from waeup.ikoba.customers.customer import Customer
     
    6668        self.product = self.app['products'][self.product_id]
    6769
     70        document = createObject('waeup.CustomerSampleDocument')
     71        document.title = u'My Samle Document'
     72        IWorkflowState(document).setState(VERIFIED)
     73        self.customer['documents'].addDocument(document)
     74        self.document_id = document.document_id
     75        self.document = self.customer['documents'][self.document_id]
     76
    6877        contract = createObject('waeup.SampleContract')
    6978        contract.title = u'My Samle Contract'
    70         contract.product = product
     79        contract.product_object = product
     80        contract.document_object = document
    7181        contract.last_product_id = product.product_id
    7282        self.customer['contracts'].addContract(contract)
    7383        self.contract_id = contract.contract_id
    7484        self.contract = self.customer['contracts'][self.contract_id]
    75 
    76         document = createObject('waeup.CustomerSampleDocument')
    77         document.title = u'My Samle Document'
    78         self.customer['documents'].addDocument(document)
    79         self.document_id = document.document_id
    80         self.document = self.customer['documents'][self.document_id]
    8185
    8286        return
     
    167171        assert len(results) == 1
    168172        assert results[0] is self.customer['contracts'][self.contract_id]
    169         assert results[0].product is self.product
     173        assert results[0].product_object is self.product
    170174
    171175    def test_product_removal(self):
    172176        # This test does not only test catalog components, it also ensures
    173         # that the product attribute of an contract is cleared
     177        # that the product object attribute of a contract is cleared
    174178        # but the last_product_id is not.
    175179        del self.app['products'][self.product_id]
    176         self.assertTrue(self.contract.product is None)
     180        self.assertTrue(self.contract.product_object is None)
    177181        self.assertEqual(self.contract.last_product_id, 'SAM')
    178182        cat = queryUtility(ICatalog, name='contracts_catalog')
     
    181185        assert len(results) == 1
    182186        assert results[0] is self.customer['contracts'][self.contract_id]
    183         assert results[0].product is None
     187        assert results[0].product_object is None
    184188        # Product removal is being logged in customers.log
    185189        logfile = os.path.join(
     
    190194            in logcontent)
    191195
     196    def test_document_removal(self):
     197        # Actually, this test does not test catalog components at all.
     198        # Tt only ensures that the document object attributes of a contract
     199        # are cleared, like in the test_product_removal above.
     200        del self.customer['documents'][self.document_id]
     201        self.assertTrue(self.contract.document_object is None)
     202        # Document removal is being logged in customers.log
     203        logfile = os.path.join(
     204            self.app['datacenter'].storage, 'logs', 'customers.log')
     205        logcontent = open(logfile).read()
     206        self.assertTrue(
     207            'INFO - system - ObjectRemovedEvent - K1000000 - c101 - removed: d101\n'
     208            in logcontent)
     209
Note: See TracChangeset for help on using the changeset viewer.