Changeset 12355 for main/ikobacustom.skeleton/trunk/src
- Timestamp:
- 31 Dec 2014, 17:12:41 (10 years ago)
- Location:
- main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/documents.py
r12286 r12355 34 34 35 35 grok.implements(ISkeletonCustomerDocument, ICustomerNavigation) 36 grok.provides(ISkeletonCustomerDocument) 36 37 37 38 # Ikoba can store any number of files per Document object. -
main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/tests/test_browser.py
r12354 r12355 29 29 from hurry.workflow.interfaces import IWorkflowState 30 30 from waeup.ikoba.customers.tests.test_batching import CustomerImportExportSetup 31 from waeup.ikoba.customers.tests.test_browser import CustomersFullSetup 31 32 from ikobacustom.skeleton.customers.export import ( 32 33 SkeletonCustomerExporter, … … 39 40 from ikobacustom.skeleton.testing import FunctionalLayer 40 41 42 SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') 43 SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp') 44 SAMPLE_PDF = os.path.join(os.path.dirname(__file__), 'test_pdf.pdf') 41 45 42 46 class CustomerImportExportTest(CustomerImportExportSetup): … … 202 206 self.assertEqual(num_fail,0) 203 207 return 208 209 class DocumentUITests(CustomersFullSetup): 210 # Tests for customer document related views and pages 211 212 layer = FunctionalLayer 213 214 def test_manage_upload_pdf_file(self): 215 # Managers can upload a file via the DocumentManageFormPage 216 # The image is stored even if form has errors 217 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 218 self.browser.open(self.customer_path + '/documents') 219 self.browser.getControl("Add document").click() 220 self.browser.getControl(name="doctype").value = ['SkeletonCustomerDocument'] 221 self.browser.getControl(name="form.title").value = 'My Skeleton Document' 222 self.browser.getControl("Add document").click() 223 docid = [i for i in self.customer['documents'].keys() if len(i) > 10][0] 224 self.browser.open(self.documents_path + '/%s/manage' % docid) 225 # Create a pseudo image file and select it to be uploaded 226 image = open(SAMPLE_IMAGE, 'rb') 227 ctrl = self.browser.getControl(name='pdfscanmanageupload') 228 file_ctrl = ctrl.mech_control 229 file_ctrl.add_file(image, filename='my_sample_scan.jpg') 230 self.browser.getControl( 231 name='upload_pdfscanmanageupload').click() 232 self.assertTrue( 233 'pdf file extension expected' in self.browser.contents) 234 ctrl = self.browser.getControl(name='pdfscanmanageupload') 235 file_ctrl = ctrl.mech_control 236 file_ctrl.add_file(image, filename='my_sample_scan.pdf') 237 self.browser.getControl( 238 name='upload_pdfscanmanageupload').click() 239 self.assertTrue( 240 'Could not determine file type' in self.browser.contents) 241 pdf = open(SAMPLE_PDF, 'rb') 242 ctrl = self.browser.getControl(name='pdfscanmanageupload') 243 file_ctrl = ctrl.mech_control 244 file_ctrl.add_file(pdf, filename='my_sample_scan.pdf') 245 self.browser.getControl( 246 name='upload_pdfscanmanageupload').click() 247 self.assertTrue( 248 'href="http://localhost/app/customers/K1000000/documents/%s/sample.pdf">PDF File</a>' 249 % docid in self.browser.contents) 250 # Browsing the link shows a real pdf 251 self.browser.open('sample.pdf') 252 self.assertEqual( 253 self.browser.headers['content-type'], 'application/pdf') -
main/ikobacustom.skeleton/trunk/src/ikobacustom/skeleton/customers/utils.py
r12286 r12355 19 19 """ 20 20 21 from copy import deepcopy 21 22 from waeup.ikoba.customers.utils import CustomersUtils 22 23 from ikobacustom.skeleton.interfaces import MessageFactory as _ … … 31 32 'CustomerPDFDocument': _('PDF Document'), 32 33 33 'Skeleton SampleDocument': _('Skeleton Document'),34 'SkeletonCustomerDocument': _('Skeleton Document'), 34 35 } 35 36 … … 40 41 } 41 42 42 SELECTABLE_DOCTYPES_DICT = DOCTYPES_DICT43 SELECTABLE_DOCTYPES_DICT = deepcopy(DOCTYPES_DICT) 43 44 44 SELECTABLE_CONTYPES_DICT = CONTYPES_DICT45 SELECTABLE_CONTYPES_DICT = deepcopy(CONTYPES_DICT)
Note: See TracChangeset for help on using the changeset viewer.