Changeset 16548 for main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests
- Timestamp:
- 13 Jul 2021, 16:25:31 (3 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/applicants/tests/test_browser.py
r16240 r16548 32 32 from waeup.kofa.applicants.tests.test_browser import ( 33 33 ApplicantsFullSetup, container_name_1, session_1) 34 35 SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') 34 36 35 37 class CustomApplicantUITest(ApplicantsFullSetup): … … 344 346 self.browser.open(self.transapplicant_manage_path) 345 347 # Create a pseudo file with acceptable size 346 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 347 pseudo_pdf = StringIO(pdf_content) 348 ctrl = self.browser.getControl(name='stateresult.pdf') 348 #pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 349 #pseudo_pdf = StringIO(pdf_content) 350 image = open(SAMPLE_IMAGE, 'rb') 351 ctrl = self.browser.getControl(name='stateresult') 349 352 file_ctrl = ctrl.mech_control 350 file_ctrl.add_file( pseudo_pdf, filename='myform.pdf')353 file_ctrl.add_file(image, filename='my_scan.jpg') 351 354 self.browser.getControl("Save").click() # submit form 352 355 # Even though the form could not be saved ... 353 356 self.assertTrue('Required input is missing' in self.browser.contents) 354 357 # ... the file has been successfully uploaded 355 pdf_url = self.transapplicant_manage_path.replace('manage', 'stateresult.pdf')356 self.browser.open( pdf_url)358 image_url = self.transapplicant_manage_path.replace('manage', 'stateresult') 359 self.browser.open(image_url) 357 360 self.assertEqual( 358 self.browser.headers['content-type'], ' application/pdf')359 self.assertEqual(len(self.browser.contents), 307200)361 self.browser.headers['content-type'], 'image/jpeg') 362 self.assertEqual(len(self.browser.contents), 2787) 360 363 # There is really a file stored for the applicant 361 364 storage = getUtility(IExtFileStore) … … 365 368 fd = storage.getFile(file_id) 366 369 file_len = len(fd.read()) 367 self.assertEqual(file_len, 307200)370 self.assertEqual(file_len, 2787) 368 371 # A file link is displayed on the edit view ... 369 372 self.browser.open(self.transapplicant_manage_path) 370 self.assertTrue('<a href="stateresult .pdf">' in self.browser.contents)373 self.assertTrue('<a href="stateresult">' in self.browser.contents) 371 374 # ... and on the dislay view 372 375 self.browser.open(self.transapplicant_view_path) 373 self.assertTrue('stateresult .pdf">Statement of Result</a>'376 self.assertTrue('stateresult">Statement of Result</a>' 374 377 in self.browser.contents) 375 378 # Adding file is properly logged … … 416 419 self.browser.open(self.verapplicant_manage_path) 417 420 # Create a pseudo file with acceptable size 418 pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 419 pseudo_pdf = StringIO(pdf_content) 420 ctrl = self.browser.getControl(name='verificationdoc.pdf') 421 #pdf_content = 'A' * 1024 * 300 # A string of 300 KB size 422 #pseudo_pdf = StringIO(pdf_content) 423 image = open(SAMPLE_IMAGE, 'rb') 424 ctrl = self.browser.getControl(name='verificationdoc') 421 425 file_ctrl = ctrl.mech_control 422 file_ctrl.add_file( pseudo_pdf, filename='myform.pdf')426 file_ctrl.add_file(image, filename='my_scan.jpg') 423 427 self.browser.getControl("Save").click() # submit form 424 428 # Even though the form could not be saved ... 425 429 self.assertTrue('Required input is missing' in self.browser.contents) 426 430 # ... the file has been successfully uploaded 427 pdf_url = self.verapplicant_manage_path.replace('manage', 'verificationdoc.pdf')428 self.browser.open( pdf_url)431 image_url = self.verapplicant_manage_path.replace('manage', 'verificationdoc') 432 self.browser.open(image_url) 429 433 self.assertEqual( 430 self.browser.headers['content-type'], ' application/pdf')431 self.assertEqual(len(self.browser.contents), 307200)434 self.browser.headers['content-type'], 'image/jpeg') 435 self.assertEqual(len(self.browser.contents), 2787) 432 436 # There is really a file stored for the applicant 433 437 storage = getUtility(IExtFileStore) … … 437 441 fd = storage.getFile(file_id) 438 442 file_len = len(fd.read()) 439 self.assertEqual(file_len, 307200)443 self.assertEqual(file_len, 2787) 440 444 # A file link is displayed on the edit view ... 441 445 self.browser.open(self.verapplicant_manage_path) 442 self.assertTrue('<a href="verificationdoc .pdf">' in self.browser.contents)446 self.assertTrue('<a href="verificationdoc">' in self.browser.contents) 443 447 # ... and on the dislay view 444 448 self.browser.open(self.verapplicant_view_path) 445 self.assertTrue('verificationdoc .pdf">Result/Certificate Document</a>'449 self.assertTrue('verificationdoc">Result/Certificate Document</a>' 446 450 in self.browser.contents) 447 451 # Adding file is properly logged … … 454 458 % (self.verapplicant.applicant_id) 455 459 in logcontent) 456 # When an applicant is removed, also the pdffiles are gone.460 # When an applicant is removed, also the files are gone. 457 461 del self.app['applicants'][self.vercontainer.code][self.verapplicant.application_number] 458 462 fd = storage.getFile(file_id)
Note: See TracChangeset for help on using the changeset viewer.