Ignore:
Timestamp:
13 Jul 2021, 16:25:31 (3 years ago)
Author:
Henrik Bettermann
Message:

Adjust to changes in base package.

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  
    3232from waeup.kofa.applicants.tests.test_browser import (
    3333    ApplicantsFullSetup, container_name_1, session_1)
     34
     35SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg')
    3436
    3537class CustomApplicantUITest(ApplicantsFullSetup):
     
    344346        self.browser.open(self.transapplicant_manage_path)
    345347        # 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')
    349352        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')
    351354        self.browser.getControl("Save").click() # submit form
    352355        # Even though the form could not be saved ...
    353356        self.assertTrue('Required input is missing' in self.browser.contents)
    354357        # ... 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)
    357360        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)
    360363        # There is really a file stored for the applicant
    361364        storage = getUtility(IExtFileStore)
     
    365368        fd = storage.getFile(file_id)
    366369        file_len = len(fd.read())
    367         self.assertEqual(file_len, 307200)
     370        self.assertEqual(file_len, 2787)
    368371        # A file link is displayed on the edit view ...
    369372        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)
    371374        # ... and on the dislay view
    372375        self.browser.open(self.transapplicant_view_path)
    373         self.assertTrue('stateresult.pdf">Statement of Result</a>'
     376        self.assertTrue('stateresult">Statement of Result</a>'
    374377            in self.browser.contents)
    375378        # Adding file is properly logged
     
    416419        self.browser.open(self.verapplicant_manage_path)
    417420        # 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')
    421425        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')
    423427        self.browser.getControl("Save").click() # submit form
    424428        # Even though the form could not be saved ...
    425429        self.assertTrue('Required input is missing' in self.browser.contents)
    426430        # ... 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)
    429433        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)
    432436        # There is really a file stored for the applicant
    433437        storage = getUtility(IExtFileStore)
     
    437441        fd = storage.getFile(file_id)
    438442        file_len = len(fd.read())
    439         self.assertEqual(file_len, 307200)
     443        self.assertEqual(file_len, 2787)
    440444        # A file link is displayed on the edit view ...
    441445        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)
    443447        # ... and on the dislay view
    444448        self.browser.open(self.verapplicant_view_path)
    445         self.assertTrue('verificationdoc.pdf">Result/Certificate Document</a>'
     449        self.assertTrue('verificationdoc">Result/Certificate Document</a>'
    446450            in self.browser.contents)
    447451        # Adding file is properly logged
     
    454458            % (self.verapplicant.applicant_id)
    455459            in logcontent)
    456         # When an applicant is removed, also the pdf files are gone.
     460        # When an applicant is removed, also the files are gone.
    457461        del self.app['applicants'][self.vercontainer.code][self.verapplicant.application_number]
    458462        fd = storage.getFile(file_id)
Note: See TracChangeset for help on using the changeset viewer.