Changeset 16546 for main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests/test_browser.py
- Timestamp:
- 13 Jul 2021, 16:05:29 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/tests/test_browser.py
r16292 r16546 41 41 from kofacustom.iuokada.applicants.export import CustomApplicantExporter 42 42 from kofacustom.iuokada.applicants.batching import CustomApplicantProcessor 43 44 SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') 43 45 44 46 class CustomApplicantUITests(ApplicantsFullSetup): … … 159 161 self.browser.open(self.transapplicant_manage_path) 160 162 # Create a pseudo file with acceptable size 161 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 162 pseudo_pdf = StringIO(pdf_content) 163 ctrl = self.browser.getControl(name='res_stat.pdf') 163 #pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 164 #pseudo_pdf = StringIO(pdf_content) 165 image = open(SAMPLE_IMAGE, 'rb') 166 ctrl = self.browser.getControl(name='res_stat') 164 167 file_ctrl = ctrl.mech_control 165 file_ctrl.add_file( pseudo_pdf, filename='myform.pdf')168 file_ctrl.add_file(image, filename='my_scan.jpg') 166 169 self.browser.getControl("Save").click() # submit form 167 170 # Even though the form could not be saved ... 168 171 self.assertTrue('Required input is missing' in self.browser.contents) 169 172 # ... the file has been successfully uploaded 170 pdf_url = self.transapplicant_manage_path.replace('manage', 'res_stat.pdf')171 self.browser.open( pdf_url)173 image_url = self.transapplicant_manage_path.replace('manage', 'res_stat') 174 self.browser.open(image_url) 172 175 self.assertEqual( 173 self.browser.headers['content-type'], ' application/pdf')174 self.assertEqual(len(self.browser.contents), 307200)176 self.browser.headers['content-type'], 'image/jpeg') 177 self.assertEqual(len(self.browser.contents), 2787) 175 178 # There is really a file stored for the applicant 176 179 storage = getUtility(IExtFileStore) … … 180 183 fd = storage.getFile(file_id) 181 184 file_len = len(fd.read()) 182 self.assertEqual(file_len, 307200)185 self.assertEqual(file_len, 2787) 183 186 # A file link is displayed on the edit view ... 184 187 self.browser.open(self.transapplicant_manage_path) 185 self.assertTrue('<a href="res_stat .pdf">' in self.browser.contents)188 self.assertTrue('<a href="res_stat">' in self.browser.contents) 186 189 # ... and on the dislay view 187 190 self.browser.open(self.transapplicant_view_path) 188 self.assertTrue('res_stat .pdf">Statement of Result</a>'191 self.assertTrue('res_stat">Statement of Result</a>' 189 192 in self.browser.contents) 190 193 # Adding file is properly logged … … 194 197 self.assertTrue( 195 198 'zope.mgr - kofacustom.iuokada.applicants.browser.CustomApplicantManageFormPage' 196 ' - %s - saved: res_stat .pdf'199 ' - %s - saved: res_stat' 197 200 % (self.transapplicant.applicant_id) 198 201 in logcontent)
Note: See TracChangeset for help on using the changeset viewer.