- Timestamp:
- 8 Mar 2016, 17:21:35 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r13755 r13770 22 22 import grok 23 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 from zope.securitypolicy.interfaces import IPrincipalRoleManager 24 25 from datetime import datetime, timedelta, date 25 26 from mechanize import LinkNotFoundError … … 33 34 from waeup.kofa.students.accommodation import BedTicket 34 35 from waeup.kofa.testing import FunctionalTestCase 36 from waeup.kofa.authentication import LocalRoleSetEvent 35 37 from waeup.kofa.browser.tests.test_pdf import samples_dir 36 38 from waeup.aaue.testing import FunctionalLayer … … 634 636 in self.browser.contents) 635 637 return 638 639 def test_handle_courses_by_lecturer(self): 640 self.app['users'].addUser('mrslecturer', 'mrslecturersecret') 641 self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng' 642 self.app['users']['mrslecturer'].title = u'Mercedes Benz' 643 # Add course ticket 644 studylevel = createObject(u'waeup.StudentStudyLevel') 645 studylevel.level = 100 646 studylevel.level_session = 2004 647 self.student['studycourse'].addStudentStudyLevel( 648 self.certificate, studylevel) 649 # Assign local Lecturer role for a certificate. 650 course = self.app['faculties']['fac1']['dep1'].courses['COURSE1'] 651 prmlocal = IPrincipalRoleManager(course) 652 prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer') 653 notify(LocalRoleSetEvent( 654 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True)) 655 # Login as lecturer. 656 self.browser.open(self.login_path) 657 self.browser.getControl(name="form.login").value = 'mrslecturer' 658 self.browser.getControl(name="form.password").value = 'mrslecturersecret' 659 self.browser.getControl("Login").click() 660 self.browser.getLink("My Roles").click() 661 self.browser.getLink( 662 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click() 663 # Course results can be batch edited via the edit_courses view. 664 self.app['faculties']['fac1']['dep1'].score_editing_disabled = False 665 self.app['configuration'].current_academic_session = 2004 666 IWorkflowState(self.student).setState('courses validated') 667 self.browser.open( 668 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 669 self.assertTrue( 670 'input type="text" name="scores"' 671 in self.browser.contents) 672 self.browser.getControl(name="scores", index=0).value = '55' 673 self.browser.getControl(name="cas", index=0).value = '66' 674 self.browser.getControl("Update scores").click() 675 # New score and ca has been set. 676 self.assertEqual( 677 self.student['studycourse']['100']['COURSE1'].score, 55) 678 self.assertEqual( 679 self.student['studycourse']['100']['COURSE1'].ca, 66) 680 # Score editing has been logged. 681 logfile = os.path.join( 682 self.app['datacenter'].storage, 'logs', 'students.log') 683 logcontent = open(logfile).read() 684 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 685 'E1000000 100/COURSE1 score updated (55)' in logcontent) 686 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 687 'E1000000 100/COURSE1 ca updated (66)' in logcontent) 688 # Non-integer scores won't be accepted. 689 self.browser.open( 690 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 691 self.assertTrue('value="55" />' in self.browser.contents) 692 self.browser.getControl(name="scores", index=0).value = 'abc' 693 self.browser.getControl("Update scores").click() 694 self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.' 695 in self.browser.contents) 696 # Scores can be removed. 697 self.browser.open( 698 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 699 self.browser.getControl(name="scores", index=0).value = '' 700 self.browser.getControl("Update scores").click() 701 self.assertEqual( 702 self.student['studycourse']['100']['COURSE1'].score, None) 703 logcontent = open(logfile).read() 704 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 705 'E1000000 100/COURSE1 score updated (None)' in logcontent)
Note: See TracChangeset for help on using the changeset viewer.