Changeset 16928 for main/waeup.fceokene


Ignore:
Timestamp:
20 Apr 2022, 04:27:51 (3 years ago)
Author:
Henrik Bettermann
Message:

Add tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py

    r16926 r16928  
    105105        self.tpucontainer.enddate = datetime.datetime.now(pytz.utc) + delta
    106106
     107        # Add utp applicants container
     108        self.utpcontainer = ApplicantsContainer()
     109        self.utpcontainer.mode = 'create'
     110        self.utpcontainer.code = u'utp%s' % session
     111        self.utpcontainer.prefix = u'utp'
     112        self.utpcontainer.application_category = u'basic'
     113        self.utpcontainer.year = session
     114        self.utpcontainer.application_fee = 300.0
     115        self.utpcontainer.title = u'This is the utp%s container' % session
     116        self.app['applicants'][self.utpcontainer.code] = self.utpcontainer
     117        delta = datetime.timedelta(days=10)
     118        self.utpcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
     119        self.utpcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
     120
    107121        # Populate university
    108122        self.certificate = createObject('waeup.Certificate')
     
    150164            self.app['applicants'][self.tpucontainer.code][
    151165            self.tpuapplicant.application_number]).setPassword('apwd')
     166
     167        utpapplicant = createObject(u'waeup.Applicant')
     168        utpapplicant.firstname = u'Michelle'
     169        utpapplicant.lastname = u'Obama'
     170        self.app['applicants'][self.utpcontainer.code].addApplicant(utpapplicant)
     171        self.utpapplication_number = utpapplicant.application_number
     172        self.utpapplicant = self.app['applicants'][self.utpcontainer.code][
     173            self.utpapplication_number]
     174        self.utpapplicant_path = ('http://localhost/app/applicants/utp%s/%s'
     175            % (session, self.utpapplication_number))
     176        IUserAccount(
     177            self.app['applicants'][self.utpcontainer.code][
     178            self.utpapplicant.application_number]).setPassword('apwd')
    152179
    153180        self.browser = Browser()
     
    271298        self.assertEqual(self.tpuapplicant.state, 'submitted')
    272299        return
     300
     301    def test_final_submit_utp(self):
     302        # Create BED certificate
     303        certificate1 = createObject('waeup.Certificate')
     304        certificate1.application_category = 'basic'
     305        certificate1.code = 'BEDCERT1'
     306        certificate1.title = 'BEDCert1'
     307        certificate1.start_level = 100
     308        certificate1.end_level = 500
     309        certificate1.study_mode = u'nce_ft'
     310        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     311            certificate1)
     312        IWorkflowState(self.utpapplicant).setState('paid')
     313        self.browser.open(self.login_path)
     314        self.browser.getControl(
     315            name="form.login").value = self.utpapplicant.applicant_id
     316        self.browser.getControl(name="form.password").value = 'apwd'
     317        self.browser.getControl("Login").click()
     318        self.browser.open(self.utpapplicant_path + '/edit')
     319        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
     320        self.browser.getControl(name="form.school_utp").value = ['utp0010']
     321        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT1']
     322        image = open(SAMPLE_IMAGE, 'rb')
     323        ctrl = self.browser.getControl(name='form.passport')
     324        file_ctrl = ctrl.mech_control
     325        file_ctrl.add_file(image, filename='myphoto.jpg')
     326        self.browser.getControl(name="confirm_passport").value = True
     327        self.browser.getControl("Save").click()
     328        self.browser.getControl("Finally Submit").click()
     329        self.assertTrue(
     330            'Application submitted' in self.browser.contents)
     331        # Create 10 applicants who already selected utp0010
     332        for i in range(1,11):
     333            dummy = createObject(u'waeup.Applicant')
     334            dummy.firstname = u'John'
     335            dummy.lastname = u'Doe %s' %i
     336            dummy.school_utp = 'utp0010'
     337            self.app['applicants'][
     338                self.utpcontainer.code].addApplicant(dummy)
     339            IWorkflowState(dummy).setState('submitted')
     340        IWorkflowState(self.utpapplicant).setState('paid')
     341        self.utpapplicant.locked = False
     342        self.browser.open(self.utpapplicant_path + '/edit')
     343        self.browser.getControl(name="form.school_utp").value = ['utp0010']
     344        self.browser.getControl("Finally Submit").click()
     345        self.assertTrue("Maximum number of applications per school exceeded."
     346            in self.browser.contents)
     347        self.assertEqual(self.utpapplicant.state, 'paid')
     348        # Create second certificate
     349        certificate2 = createObject('waeup.Certificate')
     350        certificate2.code = 'BEDCERT2'
     351        certificate2.title = 'BEDCert2'
     352        certificate2.application_category = 'basic'
     353        certificate2.start_level = 100
     354        certificate2.end_level = 500
     355        certificate2.study_mode = u'nce_ft'
     356        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     357            certificate2)
     358        # Create one applicant with same subject and same school
     359        dummy = createObject(u'waeup.Applicant')
     360        dummy.firstname = u'John'
     361        dummy.lastname = u'Doe %s' %i
     362        dummy.school_utp = 'utp0012'
     363        dummy.subj_comb = certificate1
     364        self.app['applicants'][
     365            self.utpcontainer.code].addApplicant(dummy)
     366        IWorkflowState(dummy).setState('submitted')
     367        self.browser.open(self.utpapplicant_path + '/edit')
     368        self.browser.getControl(name="form.school_utp").value = ['utp0012']
     369        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT1']
     370        self.browser.getControl("Finally Submit").click()
     371        self.assertTrue("Maximum number of applications per school exceeded."
     372            in self.browser.contents)
     373        # Same school with another subj_comb can be submitted
     374        self.assertEqual(self.utpapplicant.state, 'paid')
     375        self.browser.open(self.utpapplicant_path + '/edit')
     376        self.browser.getControl(name="form.school_utp").value = ['utp0012']
     377        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT2']
     378        self.browser.getControl("Finally Submit").click()
     379        self.assertEqual(self.utpapplicant.state, 'submitted')
     380        return
Note: See TracChangeset for help on using the changeset viewer.