- Timestamp:
- 20 Jan 2015, 08:31:25 (10 years ago)
- Location:
- main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_browser.py
r12488 r12499 34 34 PCNCustomerPDFDocumentExporter, 35 35 PCNCustomerJPGDocumentExporter, 36 RONContractExporter) 36 RONContractExporter, 37 ROPContractExporter) 37 38 from ikobacustom.pcn.customers.batching import ( 38 39 PCNCustomerProcessor, 39 40 PCNCustomerPDFDocumentProcessor, 40 41 PCNCustomerJPGDocumentProcessor, 41 RONContractProcessor) 42 RONContractProcessor, 43 ROPContractProcessor) 42 44 from ikobacustom.pcn.testing import FunctionalLayer, samples_dir 43 45 … … 68 70 customer['documents'].addDocument(document1) 69 71 customer['documents'].addDocument(document2) 70 contract = createObject(u'waeup.RONContract') 71 contract.tc_dict = {'en':u'Hello World'} 72 customer['contracts'].addContract(contract) 72 contract1 = createObject(u'waeup.RONContract') 73 contract1.tc_dict = {'en':u'Hello World'} 74 customer['contracts'].addContract(contract1) 75 contract2 = createObject(u'waeup.ROPContract') 76 contract2.tc_dict = {'en':u'Hello World'} 77 customer['contracts'].addContract(contract2) 73 78 self.customer = customer 74 79 self.document1 = document1 75 80 self.document2 = document2 76 self.contract = contract 81 self.contract1 = contract1 82 self.contract2 = contract2 77 83 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 78 84 return … … 206 212 return 207 213 208 def test_export_reimport_ contracts(self):214 def test_export_reimport_roncontracts(self): 209 215 # we can export all contracts in a portal 210 216 # set values we can expect in export file … … 222 228 '[u\'2015-01-18 16:40:01 WAT - Contract created by system\'],,,,' 223 229 '[],,created,,,{\'en\': u\'Hello World\'},,K1000000,,,,\r\n' 224 % self.contract .contract_id)230 % self.contract1.contract_id) 225 231 # We can reimport the file if we change the header 226 232 # (user_id -> customer_id). Not all columns are necessary. … … 233 239 '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']' 234 240 ',,,[],created,{\'en\': u\'Hello World\'},,K1000000\r\n' 235 % self.contract .contract_id)241 % self.contract1.contract_id) 236 242 result = processor.doImport( 237 243 self.outfile, … … 244 250 self.assertEqual(num_fail,1) 245 251 # We remove the original contract. 246 del self.customer['contracts'][self.contract.contract_id] 252 del self.customer['contracts'][self.contract1.contract_id] 253 result = processor.doImport( 254 self.outfile, 255 ['class_name','contract_category','contract_id','document_object', 256 'history','last_product_id','product_object','product_options', 257 'state','tc_dict','title','customer_id'], 258 mode='create') 259 num_succ, num_fail, finished_path, failed_path = result 260 self.assertEqual(num_fail,0) 261 # We can import the same file in update mode. 262 result = processor.doImport( 263 self.outfile, 264 ['class_name','contract_category','contract_id','document_object', 265 'history','last_product_id','product_object','product_options', 266 'state','tc_dict','title','customer_id'], 267 mode='update') 268 num_succ, num_fail, finished_path, failed_path = result 269 self.assertEqual(num_succ,1) 270 self.assertEqual(num_fail,0) 271 return 272 273 def test_export_reimport_ropcontracts(self): 274 # we can export all contracts in a portal 275 # set values we can expect in export file 276 self.setup_for_export() 277 exporter = ROPContractExporter() 278 exporter.export_all(self.app, self.outfile) 279 result = open(self.outfile, 'rb').read() 280 self.assertMatches(result, 281 'category_practice,class_name,contract_category,contract_id,' 282 'date_of_birth,history,last_product_id,lga,product_object,' 283 'product_options,res_address,state,state_of_origin,superintendent,' 284 'tc_dict,title,user_id,work_address,work_email,work_phone,' 285 'year_qualification\r\n' 286 ',ROPContract,rop,%s,,' 287 '[u\'2015-01-18 16:40:01 WAT - Contract created by system\'],,,,' 288 '[],,created,,,{\'en\': u\'Hello World\'},,K1000000,,,,\r\n' 289 % self.contract2.contract_id) 290 # We can reimport the file if we change the header 291 # (user_id -> customer_id). Not all columns are necessary. 292 processor = ROPContractProcessor() 293 open(self.outfile, 'wb').write( 294 'class_name,contract_category,contract_id,document_object,' 295 'history,last_product_id,product_object,product_options,' 296 'state,tc_dict,title,user_id\r\n' 297 'ROPContract,rop,%s,,' 298 '[u\'2014-12-21 22:26:00 WAT - Contract created by system\']' 299 ',,,[],created,{\'en\': u\'Hello World\'},,K1000000\r\n' 300 % self.contract2.contract_id) 301 result = processor.doImport( 302 self.outfile, 303 ['class_name','contract_category','contract_id','document_object', 304 'history','last_product_id','product_object','product_options', 305 'state','tc_dict','title','customer_id'], 306 mode='create') 307 num, num_fail, finished_path, failed_path = result 308 # The object exists. 309 self.assertEqual(num_fail,1) 310 # We remove the original contract. 311 del self.customer['contracts'][self.contract2.contract_id] 247 312 result = processor.doImport( 248 313 self.outfile, -
main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/tests/test_contract.py
r12484 r12499 29 29 30 30 from ikobacustom.pcn.testing import (FunctionalLayer, FunctionalTestCase) 31 from ikobacustom.pcn.customers.contracts import RONContract 32 from ikobacustom.pcn.customers.interfaces import IRONContract 31 from ikobacustom.pcn.customers.contracts import RONContract, ROPContract 32 from ikobacustom.pcn.customers.interfaces import IRONContract, IROPContract 33 33 34 34 … … 42 42 verify.verifyObject(IRONContract, RONContract()) 43 43 verify.verifyObject(ICustomerNavigation, RONContract()) 44 verify.verifyObject(IROPContract, ROPContract()) 45 verify.verifyObject(ICustomerNavigation, ROPContract()) 44 46 return 45 47 46 48 def test_addContract(self): 47 49 container = ContractsContainer() 48 contract = createObject(u'waeup.RONContract')49 id = contract.contract_id50 container.addContract(contract )51 self.assertEqual(container[id ], contract)50 contract1 = createObject(u'waeup.RONContract') 51 id1 = contract1.contract_id 52 container.addContract(contract1) 53 self.assertEqual(container[id1], contract1) 52 54 self.assertRaises(TypeError, container.addContract, object()) 53 self.assertEqual(contract.class_name, 'RONContract') 55 self.assertEqual(contract1.class_name, 'RONContract') 56 57 contract2 = createObject(u'waeup.ROPContract') 58 id2 = contract2.contract_id 59 container.addContract(contract2) 60 self.assertEqual(container[id2], contract2) 61 self.assertRaises(TypeError, container.addContract, object()) 62 self.assertEqual(contract2.class_name, 'ROPContract') 54 63 return
Note: See TracChangeset for help on using the changeset viewer.