Changeset 8908 for main/waeup.fceokene/trunk/src/waeup/fceokene/students
- Timestamp:
- 4 Jul 2012, 07:46:38 (12 years ago)
- Location:
- main/waeup.fceokene/trunk/src/waeup/fceokene
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.fceokene/trunk/src/waeup/fceokene
- Property svn:mergeinfo changed
/main/waeup.uniben/trunk/src/waeup/uniben merged: 8906
- Property svn:mergeinfo changed
-
main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_browser.py
r8722 r8908 29 29 from waeup.kofa.interfaces import ( 30 30 IExtFileStore, IFileStoreNameChooser) 31 from waeup.kofa.students.batching import StudentProcessor32 31 from waeup.kofa.students.interfaces import IStudentsUtils 33 from waeup.fceokene.students.batching import CustomStudentProcessor34 32 from waeup.fceokene.testing import FunctionalLayer 35 from waeup.fceokene.students.interfaces import ( 36 ICustomStudentStudyCourse, ICustomStudent, 37 ICustomStudentStudyLevel, ICustomCourseTicket) 38 39 40 STUDENT_SAMPLE_DATA = open( 41 os.path.join(os.path.dirname(__file__), 'sample_student_data.csv'), 42 'rb').read() 43 44 STUDENT_HEADER_FIELDS = STUDENT_SAMPLE_DATA.split( 45 '\n')[0].split(',') 33 46 34 47 35 class StudentProcessorTest(FunctionalTestCase): … … 68 56 setSite(app) 69 57 70 self.processor_base = StudentProcessor()71 self.processor = CustomStudentProcessor()72 self.workdir = tempfile.mkdtemp()73 self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv')74 open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA)75 58 76 59 def tearDown(self): … … 81 64 return 82 65 83 def test_import(self):84 # We have an empty column 'date_of_birth' in the import file.85 # The original processor will fail because 'date_of_birth' is required86 # in the base package.87 num, num_warns, fin_file, fail_file = self.processor_base.doImport(88 self.csv_file, STUDENT_HEADER_FIELDS)89 self.assertEqual(num_warns,3)90 assert len(self.app['students'].keys()) == 091 # The customized processor does not complain since 'date_of_birth' is92 # not required in the custom package.93 num, num_warns, fin_file, fail_file = self.processor.doImport(94 self.csv_file, STUDENT_HEADER_FIELDS)95 #print open(fail_file).read()96 self.assertEqual(num_warns,0)97 assert len(self.app['students'].keys()) == 398 shutil.rmtree(os.path.dirname(fin_file))99 100 101 66 class StudentUITests(StudentsFullSetup): 102 67 """Tests for customized student class views and pages … … 104 69 105 70 layer = FunctionalLayer 106 107 def test_classes(self):108 # Let's see if objects created in the customized109 # portal really implement the customized interfaces110 verify.verifyObject(ICustomStudent, self.student)111 verify.verifyObject(112 ICustomStudentStudyCourse, self.student['studycourse'])113 studylevel = createObject(u'waeup.StudentStudyLevel')114 verify.verifyObject(ICustomStudentStudyLevel, studylevel)115 ticket = createObject(u'waeup.CourseTicket')116 verify.verifyObject(ICustomCourseTicket, ticket)117 IWorkflowState(self.student).setState('returning')118 # Let's see if next_session_allowed works as expected119 # A, ug_ft, 100120 self.assertTrue(self.student['studycourse'].next_session_allowed)121 # O, ug_ft, 100122 self.student['studycourse'].current_verdict = 'O'123 self.assertTrue(self.student['studycourse'].next_session_allowed)124 # O, ug_ft, 200125 self.student['studycourse'].current_level = 200126 self.assertFalse(self.student['studycourse'].next_session_allowed)127 # O, de_ft, 200128 self.student['studycourse'].certificate.study_mode = 'de_ft'129 self.assertTrue(self.student['studycourse'].next_session_allowed)130 # O, ph_ft, 300131 self.student['studycourse'].certificate.study_mode = 'ph_ft'132 self.student['studycourse'].current_level = 300133 self.assertTrue(self.student['studycourse'].next_session_allowed)134 # O, ph_ft, 400135 self.student['studycourse'].current_level = 400136 self.assertFalse(self.student['studycourse'].next_session_allowed)137 138 # Now we convert the certificate into a postgraduate certificate139 IWorkflowState(self.student).setState('school fee paid')140 self.certificate.study_mode = 'pg_ft'141 # ... and voila next session registration is allowed142 self.assertTrue(self.student['studycourse'].next_session_allowed)143 144 def test_manage_access(self):145 # Managers can access the pages of students146 # and can perform actions147 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')148 # The student created in the base package is an ug student149 self.browser.open(self.student_path)150 self.browser.getLink("Clearance Data").click()151 self.assertEqual(self.browser.headers['Status'], '200 Ok')152 self.assertEqual(self.browser.url, self.clearance_path)153 self.browser.getLink("Manage").click()154 self.assertEqual(self.browser.headers['Status'], '200 Ok')155 self.assertEqual(self.browser.url, self.manage_clearance_path)156 self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'157 self.browser.getControl("Save").click()158 self.assertMatches('...Form has been saved...',159 self.browser.contents)160 self.assertMatches('...First Sitting Record...',161 self.browser.contents)162 # Managers can open clearance slip of ug students163 self.browser.open(self.student_path + '/clearance.pdf')164 self.assertEqual(self.browser.headers['Status'], '200 Ok')165 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')166 # There is no pg field in the clearance form167 self.assertFalse('Second Higher Education Record'168 in self.browser.contents)169 # Now we change the study mode ...170 self.certificate.study_mode = 'pg_ft'171 self.browser.open(self.clearance_path)172 # ... and additional pg clearance fields appear173 self.assertMatches('...Second Higher Education Record...',174 self.browser.contents)175 # But also fields from the ug form are displayed176 self.assertMatches('...First Sitting Record...',177 self.browser.contents)178 # Managers can open clearance slip of pg students179 self.browser.open(self.student_path + '/clearance.pdf')180 self.assertEqual(self.browser.headers['Status'], '200 Ok')181 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')182 71 183 72 def test_manage_payments(self): … … 281 170 self.assertMatches('...Session configuration object is not...', 282 171 self.browser.contents) 283 284 def test_student_access(self):285 # Students can edit clearance data286 IWorkflowState(self.student).setState('cleared')287 self.student.clearance_locked = False288 self.browser.open(self.login_path)289 self.browser.getControl(name="form.login").value = self.student_id290 self.browser.getControl(name="form.password").value = 'spwd'291 self.browser.getControl("Login").click()292 # Even in state admitted students can't change the portait if293 # application slip exists.294 IWorkflowState(self.student).setState('admitted')295 self.browser.open(self.student_path)296 self.assertTrue('Change portrait' in self.browser.contents)297 file_store = getUtility(IExtFileStore)298 applicant_slip = 'My application slip'299 file_id = IFileStoreNameChooser(self.student).chooseName(300 attr="application_slip.pdf")301 file_store.createFile(file_id, StringIO(applicant_slip))302 self.browser.open(self.student_path)303 self.assertFalse('Change portrait' in self.browser.contents)304 self.browser.open(self.student_path + '/change_portrait')305 self.assertTrue('The requested form is locked' in self.browser.contents)306 # Student can view and edit clearance data307 self.browser.getLink("Clearance Data").click()308 self.browser.getLink("Edit").click()309 self.assertTrue('Save' in self.browser.contents)310 172 311 173 def test_get_returning_data(self):
Note: See TracChangeset for help on using the changeset viewer.