- Timestamp:
- 20 Nov 2014, 09:10:54 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/export.py
r12006 r12007 157 157 """Treat location values special. 158 158 """ 159 if name == 'history': 160 value = value.messages 159 161 if context is not None: 160 162 customer = context.customer -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_export.py
r11997 r12007 10 10 from waeup.ikoba.customers.catalog import CustomersQuery 11 11 from waeup.ikoba.customers.export import ( 12 CustomersExporter, get_customers)12 CustomersExporter, CustomerDocumentsExporter, get_customers) 13 13 from waeup.ikoba.customers.interfaces import ICSVCustomerExporter 14 14 from waeup.ikoba.customers.customer import Customer 15 from waeup.ikoba.customers.documents import CustomerDocument 15 16 from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup 16 17 from waeup.ikoba.testing import FunctionalLayer … … 106 107 ) 107 108 return 109 110 class CustomerDocumentsExporterTest(CustomerImportExportSetup): 111 112 layer = FunctionalLayer 113 114 def setUp(self): 115 super(CustomerDocumentsExporterTest, self).setUp() 116 self.setup_for_export() 117 return 118 119 def test_ifaces(self): 120 # make sure we fullfill interface contracts 121 obj = CustomerDocumentsExporter() 122 verifyObject(ICSVCustomerExporter, obj) 123 verifyClass(ICSVCustomerExporter, CustomerDocumentsExporter) 124 return 125 126 def test_get_as_utility(self): 127 # we can get a documents exporter as utility 128 result = queryUtility(ICSVExporter, name="customerdocuments") 129 self.assertTrue(result is not None) 130 return 131 132 def test_export_empty(self): 133 # we can export a nearly empty document 134 document = CustomerDocument() 135 exporter = CustomerDocumentsExporter() 136 exporter.export([document], self.outfile) 137 result = open(self.outfile, 'rb').read() 138 self.assertEqual( 139 result, 140 'doctype,document_id,history,title,customer_id\r\n' 141 ',d101,[],,\r\n' 142 ) 143 return 144 145 def test_export(self): 146 # we can really export customer documents. 147 # set values we can expect in export file 148 self.setup_customer(self.customer) 149 document = self.customer['documents']['d101'] 150 exporter = CustomerDocumentsExporter() 151 exporter.export([document], self.outfile) 152 result = open(self.outfile, 'rb').read() 153 self.assertTrue( 154 'doctype,document_id,history,title,customer_id\r\n' 155 in result 156 ) 157 self.assertTrue( 158 'Document created by system\'],My Document,A111111\r\n' 159 in result 160 ) 161 return 162 163 def test_export_all(self): 164 # we can really export all documents 165 # set values we can expect in export file 166 self.setup_customer(self.customer) 167 exporter = CustomerDocumentsExporter() 168 exporter.export_all(self.app, self.outfile) 169 result = open(self.outfile, 'rb').read() 170 self.assertTrue( 171 'doctype,document_id,history,title,customer_id\r\n' 172 in result) 173 self.assertTrue( 174 ' Document created by system\'],My Document,A111111\r\n' 175 in result) 176 return 177 178 def test_export_customer(self): 179 # we can really export all documents of a certain customer 180 # set values we can expect in export file 181 self.setup_customer(self.customer) 182 exporter = CustomerDocumentsExporter() 183 exporter.export_customer(self.customer, self.outfile) 184 result = open(self.outfile, 'rb').read() 185 self.assertTrue( 186 'doctype,document_id,history,title,customer_id\r\n' 187 in result) 188 self.assertTrue( 189 ' Document created by system\'],My Document,A111111\r\n' 190 in result) 191 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py
r12005 r12007 23 23 from waeup.ikoba.interfaces import MessageFactory as _ 24 24 25 class Document CategorySource(ContextualDictSourceFactoryBase):25 class DocumentTypeSource(ContextualDictSourceFactoryBase): 26 26 """A document type source delivers all types of documents. 27 27 … … 46 46 history = Attribute('Object history, a list of messages') 47 47 48 category= schema.Choice(49 title = _(u'Document Category'),50 source = Document CategorySource(),48 doctype = schema.Choice( 49 title = _(u'Document Type'), 50 source = DocumentTypeSource(), 51 51 required = True, 52 52 )
Note: See TracChangeset for help on using the changeset viewer.