Changeset 13937 for main/waeup.aaue/trunk/src/waeup/aaue/students/tests
- Timestamp:
- 14 Jun 2016, 15:55:07 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r13909 r13937 21 21 import pytz 22 22 import grok 23 from StringIO import StringIO 23 24 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 25 from zope.securitypolicy.interfaces import IPrincipalRoleManager … … 31 32 from zope.catalog.interfaces import ICatalog 32 33 from waeup.kofa.app import University 34 from waeup.kofa.interfaces import VALIDATED 33 35 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 34 36 from waeup.kofa.students.accommodation import BedTicket … … 72 74 return 73 75 76 UPLOAD_CSV_TEMPLATE = ( 77 'matric_number,student_id,display_fullname,level,code,level_session,' 78 'score,ca\r\n' 79 '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s\r\n') 80 74 81 class OfficerUITests(StudentsFullSetup): 75 82 # Tests for Student class views and pages 76 83 77 84 layer = FunctionalLayer 85 86 def login_as_lecturer(self): 87 self.app['users'].addUser('mrslecturer', 'mrslecturersecret') 88 self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng' 89 self.app['users']['mrslecturer'].title = u'Mercedes Benz' 90 # Add course ticket 91 studylevel = createObject(u'waeup.StudentStudyLevel') 92 studylevel.level = 100 93 studylevel.level_session = 2004 94 self.student['studycourse'].addStudentStudyLevel( 95 self.certificate, studylevel) 96 # Assign local Lecturer role for a certificate. 97 course = self.app['faculties']['fac1']['dep1'].courses['COURSE1'] 98 prmlocal = IPrincipalRoleManager(course) 99 prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer') 100 notify(LocalRoleSetEvent( 101 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True)) 102 # Login as lecturer. 103 self.browser.open(self.login_path) 104 self.browser.getControl(name="form.login").value = 'mrslecturer' 105 self.browser.getControl( 106 name="form.password").value = 'mrslecturersecret' 107 self.browser.getControl("Login").click() 108 # Store reused urls/paths 109 self.course_url = ( 110 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1') 111 self.edit_scores_url = '%s/edit_scores' % self.course_url 112 # Set standard parameters 113 self.app['configuration'].current_academic_session = 2004 114 self.app['faculties']['fac1']['dep1'].score_editing_disabled = False 115 IWorkflowState(self.student).setState(VALIDATED) 116 78 117 79 118 def test_gpa_calculation(self): … … 281 320 return 282 321 322 def test_scores_csv_upload_available(self): 323 # lecturers can upload a CSV file to set values. 324 self.login_as_lecturer() 325 # set value to change from 326 self.student['studycourse']['100']['COURSE1'].score = 55 327 self.browser.open(self.edit_scores_url) 328 upload_ctrl = self.browser.getControl(name='uploadfile:file') 329 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','77')) 330 upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv') 331 self.browser.getControl("Update editable scores from").click() 332 # value changed 333 self.assertEqual( 334 self.student['studycourse']['100']['COURSE1'].score, 65) 335 self.assertEqual( 336 self.student['studycourse']['100']['COURSE1'].ca, 77) 337 283 338 class StudentUITests(StudentsFullSetup): 284 339 """Tests for customized student class views and pages … … 688 743 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 689 744 self.assertTrue( 690 'input type="text" name="scores "'691 in self.browser.contents) 692 self.browser.getControl(name="scores ", index=0).value = '55'693 self.browser.getControl(name="cas ", index=0).value = '66'694 self.browser.getControl("Update scores ").click()745 'input type="text" name="scores:list"' 746 in self.browser.contents) 747 self.browser.getControl(name="scores:list", index=0).value = '55' 748 self.browser.getControl(name="cas:list", index=0).value = '66' 749 self.browser.getControl("Update scores from").click() 695 750 # New score and ca has been set. 696 751 self.assertEqual( … … 710 765 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 711 766 self.assertTrue('value="55" />' in self.browser.contents) 712 self.browser.getControl(name="scores ", index=0).value = 'abc'767 self.browser.getControl(name="scores:list", index=0).value = 'abc' 713 768 self.browser.getControl("Update scores").click() 714 769 self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.' … … 717 772 self.browser.open( 718 773 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 719 self.browser.getControl(name="scores ", index=0).value = ''774 self.browser.getControl(name="scores:list", index=0).value = '' 720 775 self.browser.getControl("Update scores").click() 721 776 self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.