- Timestamp:
- 6 Jun 2012, 09:17:37 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py
r8487 r8636 20 20 """ 21 21 import os 22 import grok 22 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 from zope.event import notify 23 25 from zope.component import getUtility 24 26 from zope.i18n import translate … … 35 37 return 36 38 37 def test_copier(self):39 def prepare_applicant(self): 38 40 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 39 41 self.browser.open(self.manage_path) … … 47 49 file_ctrl.add_file(file_obj, filename='my_photo.jpg') 48 50 self.browser.getControl("Save").click() # submit form 51 return 52 53 def test_copier(self): 54 self.prepare_applicant() 49 55 storage = getUtility(IExtFileStore) 50 56 file_id = IFileStoreNameChooser(self.applicant).chooseName() … … 100 106 101 107 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() 113 109 IWorkflowState(self.applicant).setState('admitted') 114 110 self.browser.getControl(name="form.course_admitted").value = ['CERT1'] … … 120 116 ctrl.getControl(value=self.applicant.application_number).selected = True 121 117 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') 122 145 self.assertTrue('1 students successfully created' in self.browser.contents) 123 146
Note: See TracChangeset for help on using the changeset viewer.