Ignore:
Timestamp:
6 Jun 2012, 09:17:37 (12 years ago)
Author:
Henrik Bettermann
Message:

Implement CreateAllStudentsPage? which creates students from all admitted students in a container.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r8487 r8636  
    2020"""
    2121import os
     22import grok
    2223from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     24from zope.event import notify
    2325from zope.component import getUtility
    2426from zope.i18n import translate
     
    3537        return
    3638
    37     def test_copier(self):
     39    def prepare_applicant(self):
    3840        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    3941        self.browser.open(self.manage_path)
     
    4749        file_ctrl.add_file(file_obj, filename='my_photo.jpg')
    4850        self.browser.getControl("Save").click() # submit form
     51        return
     52
     53    def test_copier(self):
     54        self.prepare_applicant()
    4955        storage = getUtility(IExtFileStore)
    5056        file_id = IFileStoreNameChooser(self.applicant).chooseName()
     
    100106
    101107    def test_batch_copying(self):
    102         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    103         self.browser.open(self.manage_path)
    104         self.fill_correct_values()
    105         self.browser.getControl("Save").click()
    106         # Upload a passport picture
    107         ctrl = self.browser.getControl(name='form.passport')
    108         file_obj = open(
    109             os.path.join(os.path.dirname(__file__), 'test_image.jpg'),'rb')
    110         file_ctrl = ctrl.mech_control
    111         file_ctrl.add_file(file_obj, filename='my_photo.jpg')
    112         self.browser.getControl("Save").click() # submit form
     108        self.prepare_applicant()
    113109        IWorkflowState(self.applicant).setState('admitted')
    114110        self.browser.getControl(name="form.course_admitted").value = ['CERT1']
     
    120116        ctrl.getControl(value=self.applicant.application_number).selected = True
    121117        self.browser.getControl("Create students from selected", index=0).click()
     118        self.assertTrue('1 students successfully created' in self.browser.contents)
     119
     120    def test_hidden_batch_copying(self):
     121        logfile = os.path.join(
     122            self.app['datacenter'].storage, 'logs', 'applicants.log')
     123        self.prepare_applicant()
     124        self.browser.open(self.container_path + '/createallstudents')
     125        self.assertTrue('No student could be created' in self.browser.contents)
     126        IWorkflowState(self.applicant).setState('admitted')
     127        notify(grok.ObjectModifiedEvent(self.applicant))
     128        self.browser.open(self.container_path + '/createallstudents')
     129        self.assertTrue('No student could be created' in self.browser.contents)
     130        logcontent = open(logfile).read()
     131        self.assertTrue('No course admitted provided' in logcontent)
     132        self.browser.open(self.manage_path)
     133        self.browser.getControl(name="form.course_admitted").value = ['CERT1']
     134        self.browser.getControl("Save").click()
     135        # date_of_birth is not required for applicants but for students
     136        self.applicant.date_of_birth = None
     137        self.browser.open(self.container_path + '/createallstudents')
     138        self.assertTrue('No student could be created' in self.browser.contents)
     139        logcontent = open(logfile).read()
     140        self.assertTrue('RequiredMissing: date_of_birth' in logcontent)
     141        self.browser.open(self.manage_path)
     142        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
     143        self.browser.getControl("Save").click()
     144        self.browser.open(self.container_path + '/createallstudents')
    122145        self.assertTrue('1 students successfully created' in self.browser.contents)
    123146
Note: See TracChangeset for help on using the changeset viewer.