Changeset 12038 for main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
- Timestamp:
- 23 Nov 2014, 05:31:13 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12037 r12038 333 333 self.browser.open(self.manage_customer_path) 334 334 image = open(SAMPLE_IMAGE_BMP, 'rb') 335 ctrl = self.browser.getControl(name='passport uploadmanage')335 ctrl = self.browser.getControl(name='passportmanageupload') 336 336 file_ctrl = ctrl.mech_control 337 337 file_ctrl.add_file(image, filename='my_photo.bmp') 338 338 self.browser.getControl( 339 name='upload_passport uploadmanage').click()339 name='upload_passportmanageupload').click() 340 340 self.assertTrue('jpg file extension expected' 341 341 in self.browser.contents) 342 ctrl = self.browser.getControl(name='passport uploadmanage')342 ctrl = self.browser.getControl(name='passportmanageupload') 343 343 file_ctrl = ctrl.mech_control 344 344 image = open(SAMPLE_IMAGE, 'rb') 345 345 file_ctrl.add_file(image, filename='my_photo.jpg') 346 346 self.browser.getControl( 347 name='upload_passport uploadmanage').click()347 name='upload_passportmanageupload').click() 348 348 self.assertTrue( 349 349 'src="http://localhost/app/customers/K1000000/passport.jpg"' … … 561 561 # Admitted customer can upload a passport picture 562 562 self.browser.getLink("Change portrait").click() 563 ctrl = self.browser.getControl(name='passport uploadedit')563 ctrl = self.browser.getControl(name='passporteditupload') 564 564 file_obj = open(SAMPLE_IMAGE, 'rb') 565 565 file_ctrl = ctrl.mech_control 566 566 file_ctrl.add_file(file_obj, filename='my_photo.jpg') 567 567 self.browser.getControl( 568 name='upload_passport uploadedit').click()568 name='upload_passporteditupload').click() 569 569 self.assertTrue( 570 570 'src="http://localhost/app/customers/K1000000/passport.jpg"' … … 786 786 self.browser.getLink("Documents").click() 787 787 self.browser.getLink("Add document").click() 788 self.browser.getControl(name="doctype").value = [' generic']788 self.browser.getControl(name="doctype").value = ['sample'] 789 789 self.browser.getControl("Create document").click() 790 self.assertTrue(' GenericDocument created.' in self.browser.contents)790 self.assertTrue('Sample Document created.' in self.browser.contents) 791 791 document = self.customer['documents']['d102'] 792 792 … … 827 827 self.assertTrue( 828 828 'INFO - zope.mgr - customers.browser.DocumentAddFormPage ' 829 '- K1000000 - added: GenericDocument %s'829 '- K1000000 - added: Sample Document %s' 830 830 % document.document_id in logcontent) 831 831 … … 845 845 self.browser.getLink("Documents").click() 846 846 self.browser.getLink("Add document").click() 847 self.browser.getControl(name="doctype").value = [' generic']847 self.browser.getControl(name="doctype").value = ['sample'] 848 848 self.browser.getControl("Create document").click() 849 self.assertTrue(' GenericDocument created.' in self.browser.contents)849 self.assertTrue('Sample Document created.' in self.browser.contents) 850 850 document = self.customer['documents']['d102'] 851 851 … … 866 866 # Costumer can upload a document. 867 867 self.browser.getLink("Edit").click() 868 ctrl = self.browser.getControl(name=' genericuploadedit')868 ctrl = self.browser.getControl(name='scaneditupload') 869 869 file_obj = open(SAMPLE_IMAGE, 'rb') 870 870 file_ctrl = ctrl.mech_control 871 871 file_ctrl.add_file(file_obj, filename='my_document.jpg') 872 872 self.browser.getControl( 873 name='upload_ genericuploadedit').click()874 self.assertTrue( 875 'href="http://localhost/app/customers/K1000000/documents/d102/ generic"'873 name='upload_scaneditupload').click() 874 self.assertTrue( 875 'href="http://localhost/app/customers/K1000000/documents/d102/scan"' 876 876 in self.browser.contents) 877 877 # Costumer can submit the form. The form is also saved. … … 890 890 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 891 891 self.browser.open(self.customer_path + '/documents/d101/manage') 892 # Create a pseudo image file and select it to be uploaded in form 893 # as generic document 892 # Create a pseudo image file and select it to be uploaded 894 893 image = open(SAMPLE_IMAGE, 'rb') 895 ctrl = self.browser.getControl(name=' genericuploadmanage')894 ctrl = self.browser.getControl(name='scanmanageupload') 896 895 file_ctrl = ctrl.mech_control 897 file_ctrl.add_file(image, filename='my_ generic_document.jpg')896 file_ctrl.add_file(image, filename='my_scan.jpg') 898 897 # The Save action does not upload files 899 898 self.browser.getControl("Save").click() # submit form 900 899 self.assertFalse( 901 'href="http://localhost/app/customers/K1000000/documents/d101/ generic"'900 'href="http://localhost/app/customers/K1000000/documents/d101/scan"' 902 901 in self.browser.contents) 903 902 # ... but the correct upload submit button does 904 903 image = open(SAMPLE_IMAGE) 905 ctrl = self.browser.getControl(name=' genericuploadmanage')904 ctrl = self.browser.getControl(name='scanmanageupload') 906 905 file_ctrl = ctrl.mech_control 907 file_ctrl.add_file(image, filename='my_ generic_document.jpg')908 self.browser.getControl( 909 name='upload_ genericuploadmanage').click()910 self.assertTrue( 911 'href="http://localhost/app/customers/K1000000/documents/d101/ generic"'906 file_ctrl.add_file(image, filename='my_scan.jpg') 907 self.browser.getControl( 908 name='upload_scanmanageupload').click() 909 self.assertTrue( 910 'href="http://localhost/app/customers/K1000000/documents/d101/scan"' 912 911 in self.browser.contents) 913 912 # Browsing the link shows a real image 914 self.browser.open(' generic')913 self.browser.open('scan') 915 914 self.assertEqual( 916 915 self.browser.headers['content-type'], 'image/jpeg') … … 919 918 self.browser.open(self.customer_path + '/documents/d101/manage') 920 919 self.assertFalse( 921 'upload_ genericuploadmanage' in self.browser.contents)920 'upload_scanmanageupload' in self.browser.contents) 922 921 # File must be deleted first 923 self.browser.getControl(name='delete_ genericuploadmanage').click()924 self.assertTrue( 925 ' genericdeleted' in self.browser.contents)922 self.browser.getControl(name='delete_scanmanageupload').click() 923 self.assertTrue( 924 'scan deleted' in self.browser.contents) 926 925 # Uploading a file which is bigger than 150k will raise an error 927 926 big_image = StringIO(open(SAMPLE_IMAGE, 'rb').read() * 75) 928 ctrl = self.browser.getControl(name=' genericuploadmanage')927 ctrl = self.browser.getControl(name='scanmanageupload') 929 928 file_ctrl = ctrl.mech_control 930 file_ctrl.add_file(big_image, filename='my_ generic_document.jpg')931 self.browser.getControl( 932 name='upload_ genericuploadmanage').click()929 file_ctrl.add_file(big_image, filename='my_scan.jpg') 930 self.browser.getControl( 931 name='upload_scanmanageupload').click() 933 932 self.assertTrue( 934 933 'Uploaded file is too big' in self.browser.contents) 935 934 # we do not rely on filename extensions given by uploaders 936 935 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 937 ctrl = self.browser.getControl(name=' genericuploadmanage')936 ctrl = self.browser.getControl(name='scanmanageupload') 938 937 file_ctrl = ctrl.mech_control 939 938 # tell uploaded file is bmp 940 file_ctrl.add_file(image, filename='my_ generic_document.bmp')941 self.browser.getControl( 942 name='upload_ genericuploadmanage').click()939 file_ctrl.add_file(image, filename='my_scan.bmp') 940 self.browser.getControl( 941 name='upload_scanmanageupload').click() 943 942 self.assertTrue( 944 943 # jpg file was recognized 945 'File generic.jpg uploaded.' in self.browser.contents)944 'File scan.jpg uploaded.' in self.browser.contents) 946 945 # Delete file again 947 self.browser.getControl(name='delete_ genericuploadmanage').click()948 self.assertTrue( 949 ' genericdeleted' in self.browser.contents)946 self.browser.getControl(name='delete_scanmanageupload').click() 947 self.assertTrue( 948 'scan deleted' in self.browser.contents) 950 949 # File names must meet several conditions 951 950 bmp_image = open(SAMPLE_IMAGE_BMP, 'rb') 952 ctrl = self.browser.getControl(name=' genericuploadmanage')951 ctrl = self.browser.getControl(name='scanmanageupload') 953 952 file_ctrl = ctrl.mech_control 954 file_ctrl.add_file(bmp_image, filename='my_ generic_document.bmp')955 self.browser.getControl( 956 name='upload_ genericuploadmanage').click()953 file_ctrl.add_file(bmp_image, filename='my_scan.bmp') 954 self.browser.getControl( 955 name='upload_scanmanageupload').click() 957 956 self.assertTrue('Only the following extensions are allowed' 958 957 in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.