- Timestamp:
- 4 Dec 2014, 12:22:03 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r12131 r12143 31 31 from waeup.ikoba.customers.catalog import CustomersQuery 32 32 from waeup.ikoba.customers.export import ( 33 CustomerExporter, CustomerDocumentExporter, get_customers) 33 CustomerExporter, CustomerDocumentExporter, ContractExporter, 34 get_customers) 34 35 from waeup.ikoba.customers.interfaces import ICSVCustomerExporter 35 36 from waeup.ikoba.customers.customer import Customer 36 37 from waeup.ikoba.customers.documents import CustomerSampleDocument 38 from waeup.ikoba.customers.contracts import SampleContract 37 39 from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup 38 40 from waeup.ikoba.testing import FunctionalLayer … … 88 90 exporter.export([self.customer], self.outfile) 89 91 result = open(self.outfile, 'rb').read() 90 self.assert True(91 'customer_id,email,firstname,lastname,middlename,phone, '92 ' reg_number,sex,suspended,suspended_comment,password,state,'93 ' history\r\n'94 ' A111111,anna@sample.com,Anna,Tester,M.,+234-123-12345#,'95 ' 123,,0,,,created'96 inresult92 self.assertMatches( 93 'customer_id,email,firstname,lastname,middlename,phone,reg_number,' 94 'sex,suspended,suspended_comment,password,state,history\r\n' 95 'A111111,anna@sample.com,Anna,Tester,M.,+234-123-12345#,123,,0,,,' 96 'created,[u\'2014-12-04 11:25:35 UTC - Customer record created ' 97 'by system\']\r\n', 98 result 97 99 ) 98 100 return … … 202 204 return 203 205 204 def test_export_customer (self):206 def test_export_customer_document(self): 205 207 # we can really export all documents of a certain customer 206 208 # set values we can expect in export file … … 219 221 ) 220 222 return 223 224 225 class ContractExporterTest(CustomerImportExportSetup): 226 227 layer = FunctionalLayer 228 229 def setUp(self): 230 super(ContractExporterTest, self).setUp() 231 self.setup_for_export() 232 return 233 234 def test_ifaces(self): 235 # make sure we fullfill interface contracts 236 obj = ContractExporter() 237 verifyObject(ICSVCustomerExporter, obj) 238 verifyClass(ICSVCustomerExporter, ContractExporter) 239 return 240 241 def test_get_as_utility(self): 242 # we can get a contracts exporter as utility 243 result = queryUtility(ICSVExporter, name="contracts") 244 self.assertTrue(result is not None) 245 return 246 247 def test_export_empty(self): 248 # we can export a nearly empty contract 249 contract = SampleContract() 250 exporter = ContractExporter() 251 exporter.export([contract], self.outfile) 252 result = open(self.outfile, 'rb').read() 253 self.assertEqual( 254 result, 255 'class_name,contract_category,contract_id,document_object,' 256 'history,is_editable,last_product_id,last_transition_date,' 257 'product_object,state,title\r\n' 258 259 'SampleContract,sample,c101,,[],1,,,,,\r\n' 260 ) 261 return 262 263 def test_export(self): 264 # we can really export customer contracts. 265 # set values we can expect in export file 266 self.setup_customer(self.customer) 267 exporter = ContractExporter() 268 exporter.export([self.contract], self.outfile) 269 result = open(self.outfile, 'rb').read() 270 self.assertMatches( 271 'class_name,contract_category,contract_id,document_object,' 272 'history,is_editable,last_product_id,last_transition_date,' 273 'product_object,state,title\r\n' 274 275 'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - ' 276 'Contract record created by system\'],0,,' 277 '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n', 278 result 279 ) 280 return 281 282 def test_export_all(self): 283 # we can really export all contracts 284 # set values we can expect in export file 285 self.setup_customer(self.customer) 286 exporter = ContractExporter() 287 exporter.export_all(self.app, self.outfile) 288 result = open(self.outfile, 'rb').read() 289 self.assertMatches( 290 'class_name,contract_category,contract_id,document_object,' 291 'history,is_editable,last_product_id,last_transition_date,' 292 'product_object,state,title\r\n' 293 294 'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - ' 295 'Contract record created by system\'],0,,' 296 '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n', 297 result 298 ) 299 return 300 301 def test_export_contract(self): 302 # we can really export all contracts of a certain customer 303 # set values we can expect in export file 304 self.setup_customer(self.customer) 305 exporter = ContractExporter() 306 exporter.export_customer(self.customer, self.outfile) 307 result = open(self.outfile, 'rb').read() 308 self.assertMatches( 309 'class_name,contract_category,contract_id,document_object,' 310 'history,is_editable,last_product_id,last_transition_date,' 311 'product_object,state,title\r\n' 312 313 'SampleContract,sample,c101,d101,[u\'2014-12-04 12:10:46 UTC - ' 314 'Contract record created by system\'],0,,' 315 '2014-12-04 12:10:46.333445#,SAM,created,My Contract\r\n', 316 result 317 ) 318 return 319
Note: See TracChangeset for help on using the changeset viewer.