Changeset 12194 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
- Timestamp:
- 11 Dec 2014, 08:12:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py
r12098 r12194 24 24 from zope.component import queryUtility, createObject 25 25 from zope.component.hooks import setSite 26 from hurry.workflow.interfaces import IWorkflowState 26 27 from waeup.ikoba.app import Company 28 from waeup.ikoba.interfaces import VERIFIED 27 29 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 28 30 from waeup.ikoba.customers.customer import Customer … … 66 68 self.product = self.app['products'][self.product_id] 67 69 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 68 77 contract = createObject('waeup.SampleContract') 69 78 contract.title = u'My Samle Contract' 70 contract.product = product 79 contract.product_object = product 80 contract.document_object = document 71 81 contract.last_product_id = product.product_id 72 82 self.customer['contracts'].addContract(contract) 73 83 self.contract_id = contract.contract_id 74 84 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_id80 self.document = self.customer['documents'][self.document_id]81 85 82 86 return … … 167 171 assert len(results) == 1 168 172 assert results[0] is self.customer['contracts'][self.contract_id] 169 assert results[0].product is self.product173 assert results[0].product_object is self.product 170 174 171 175 def test_product_removal(self): 172 176 # This test does not only test catalog components, it also ensures 173 # that the product attribute of ancontract is cleared177 # that the product object attribute of a contract is cleared 174 178 # but the last_product_id is not. 175 179 del self.app['products'][self.product_id] 176 self.assertTrue(self.contract.product is None)180 self.assertTrue(self.contract.product_object is None) 177 181 self.assertEqual(self.contract.last_product_id, 'SAM') 178 182 cat = queryUtility(ICatalog, name='contracts_catalog') … … 181 185 assert len(results) == 1 182 186 assert results[0] is self.customer['contracts'][self.contract_id] 183 assert results[0].product is None187 assert results[0].product_object is None 184 188 # Product removal is being logged in customers.log 185 189 logfile = os.path.join( … … 190 194 in logcontent) 191 195 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.