- Timestamp:
- 9 Jun 2016, 14:11:19 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/tests/test_browser.py
r13902 r13903 1 1 ## $Id$ 2 ## 2 ## 3 3 ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann 4 4 ## This program is free software; you can redistribute it and/or modify … … 6 6 ## the Free Software Foundation; either version 2 of the License, or 7 7 ## (at your option) any later version. 8 ## 8 ## 9 9 ## This program is distributed in the hope that it will be useful, 10 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 12 ## GNU General Public License for more details. 13 ## 13 ## 14 14 ## You should have received a copy of the GNU General Public License 15 15 ## along with this program; if not, write to the Free Software … … 56 56 SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp') 57 57 58 58 59 def lookup_submit_value(name, value, browser): 59 60 """Find a button with a certain value.""" … … 66 67 break 67 68 return None 69 68 70 69 71 class StudentsFullSetup(FunctionalTestCase): … … 179 181 self.app['faculties']['fac1']['dep1'].courses.addCourse( 180 182 self.course) 181 self.app['faculties']['fac1']['dep1'].certificates[ 'CERT1'].addCertCourse(182 self.course, level=100)183 self.app['faculties']['fac1']['dep1'].certificates[ 184 'CERT1'].addCertCourse(self.course, level=100) 183 185 184 186 # Configure university and hostels … … 238 240 239 241 240 241 242 class StudentsContainerUITests(StudentsFullSetup): 242 243 # Tests for StudentsContainer class views and pages … … 275 276 self.browser.getControl(name="form.reg_number").value = '123' 276 277 self.browser.getControl("Create student").click() 277 self.assertTrue( 'Registration number exists already'278 in self.browser.contents)278 self.assertTrue( 279 'Registration number exists already' in self.browser.contents) 279 280 self.browser.getControl(name="form.reg_number").value = '1234' 280 281 self.browser.getControl("Create student").click() … … 424 425 return 425 426 427 426 428 class OfficerUITests(StudentsFullSetup): 427 429 # Tests for Student class views and pages … … 440 442 studylevel.level = 100 441 443 cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1'] 442 self.student['studycourse'].addStudentStudyLevel( 443 cert,studylevel) 444 self.student['studycourse'].addStudentStudyLevel(cert, studylevel) 444 445 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 445 446 self.browser.open(self.studycourse_path + '/100/manage') 446 self.assertEqual(self.browser.url, self.studycourse_path + '/100/manage') 447 self.assertEqual( 448 self.browser.url, self.studycourse_path + '/100/manage') 447 449 self.assertEqual(self.browser.headers['Status'], '200 Ok') 448 450 … … 452 454 self.browser.getLink("Logout").click() 453 455 self.assertTrue('You have been logged out' in self.browser.contents) 454 # But we are still logged in since we've used basic authentication here. 455 # Wikipedia says: Existing browsers retain authentication information 456 # until the tab or browser is closed or the user clears the history. 457 # HTTP does not provide a method for a server to direct clients to 458 # discard these cached credentials. This means that there is no 459 # effective way for a server to "log out" the user without closing 460 # the browser. This is a significant defect that requires browser 461 # manufacturers to support a "logout" user interface element ... 456 # But we are still logged in since we've used basic 457 # authentication here. Wikipedia says: Existing browsers 458 # retain authentication information until the tab or browser 459 # is closed or the user clears the history. HTTP does not 460 # provide a method for a server to direct clients to discard 461 # these cached credentials. This means that there is no 462 # effective way for a server to "log out" the user without 463 # closing the browser. This is a significant defect that 464 # requires browser manufacturers to support a "logout" user 465 # interface element ... 462 466 self.assertTrue('Manager' in self.browser.contents) 463 467 … … 570 574 self.browser.open(self.student_path) 571 575 self.browser.getLink("Send email").click() 572 self.browser.getControl(name="form.subject").value = 'Important subject' 576 self.browser.getControl( 577 name="form.subject").value = 'Important subject' 573 578 self.browser.getControl(name="form.body").value = 'Hello!' 574 579 self.browser.getControl("Send message now").click() 575 self.assertTrue('An smtp server error occurred' in self.browser.contents) 580 self.assertTrue( 581 'An smtp server error occurred' in self.browser.contents) 576 582 self.student.email = 'xx@yy.zz' 577 583 self.browser.getControl("Send message now").click() … … 622 628 file_ctrl.add_file(image, filename='my_birth_certificate.jpg') 623 629 # The Save action does not upload files 624 self.browser.getControl("Save").click() # submit form630 self.browser.getControl("Save").click() # submit form 625 631 self.assertFalse( 626 632 '<a target="image" href="birth_certificate">' … … 660 666 'Uploaded file is too big' in self.browser.contents) 661 667 # we do not rely on filename extensions given by uploaders 662 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file668 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 663 669 ctrl = self.browser.getControl(name='birthcertificateupload') 664 670 file_ctrl = ctrl.mech_control … … 681 687 self.browser.getControl( 682 688 name='upload_birthcertificateupload').click() 683 self.assertTrue('Only the following extensions are allowed' 689 self.assertTrue( 690 'Only the following extensions are allowed' 684 691 in self.browser.contents) 685 692 … … 692 699 self.browser.getControl( 693 700 name='upload_passportuploadmanage').click() 694 self.assertTrue( 'jpg file format expected'695 in self.browser.contents)701 self.assertTrue( 702 'jpg file format expected' in self.browser.contents) 696 703 ctrl = self.browser.getControl(name='passportuploadmanage') 697 704 file_ctrl = ctrl.mech_control … … 750 757 self.assertMatches('...<span>100</span>...', self.browser.contents) 751 758 self.assertEqual(self.student['studycourse']['100'].level, 100) 752 self.assertEqual(self.student['studycourse']['100'].level_session, 2004) 759 self.assertEqual( 760 self.student['studycourse']['100'].level_session, 2004) 753 761 self.browser.getControl(name="addlevel").value = ['100'] 754 762 self.browser.getControl(name="level_session").value = ['2004'] … … 766 774 self.app['datacenter'].storage, 'logs', 'students.log') 767 775 logcontent = open(logfile).read() 768 self.assertTrue('zope.mgr - students.browser.StudyCourseManageFormPage ' 769 '- K1000000 - removed: 100' in logcontent) 776 self.assertTrue( 777 'zope.mgr - students.browser.StudyCourseManageFormPage ' 778 '- K1000000 - removed: 100' in logcontent) 770 779 # Add level again 771 780 self.browser.getControl(name="addlevel").value = ['100'] … … 790 799 self.app['datacenter'].storage, 'logs', 'students.log') 791 800 logcontent = open(logfile).read() 792 self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage ' 793 '- K1000000 - removed: COURSE1 at 100' in logcontent) 801 self.assertTrue( 802 'zope.mgr - students.browser.StudyLevelManageFormPage ' 803 '- K1000000 - removed: COURSE1 at 100' in logcontent) 794 804 self.browser.getLink("here").click() 795 805 self.browser.getControl(name="form.course").value = ['COURSE1'] … … 823 833 self.assertTrue('Grade' in self.browser.contents) 824 834 self.assertTrue('Weight' in self.browser.contents) 825 self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C') 826 self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3) 827 # We add another ticket to check if GPA will be correctly calculated 828 # (and rounded) 835 self.assertEqual( 836 self.student['studycourse']['100']['COURSE1'].grade, 'C') 837 self.assertEqual( 838 self.student['studycourse']['100']['COURSE1'].weight, 3) 839 # We add another ticket to check if GPA will be correctly 840 # calculated (and rounded) 829 841 courseticket = createObject('waeup.CourseTicket') 830 842 courseticket.code = 'ANYCODE' … … 838 850 self.browser.open(self.student_path + '/studycourse/100') 839 851 # total credits 840 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[1], 23) 852 self.assertEqual( 853 self.student['studycourse']['100'].gpa_params_rectified[1], 23) 841 854 # weigheted credits = 3 * 10 + 4 * 13 842 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[2], 82.0) 855 self.assertEqual( 856 self.student['studycourse']['100'].gpa_params_rectified[2], 82.0) 843 857 # sgpa = 82 / 23 844 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 3.565) 858 self.assertEqual( 859 self.student['studycourse']['100'].gpa_params_rectified[0], 3.565) 845 860 # Carry-over courses will be collected when next level is created 846 861 self.browser.open(self.student_path + '/studycourse/manage') … … 890 905 studylevel['COURSE1'].score = studylevel['COURSE1'].passmark + 1 891 906 # GPA is 1. 892 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 1.0) 907 self.assertEqual( 908 self.student['studycourse']['100'].gpa_params_rectified[0], 1.0) 893 909 # Set score below passmark. 894 910 studylevel['COURSE1'].score = studylevel['COURSE1'].passmark - 1 895 911 # GPA is still 0. 896 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 0.0) 912 self.assertEqual( 913 self.student['studycourse']['100'].gpa_params_rectified[0], 0.0) 897 914 studylevel2 = createObject(u'waeup.StudentStudyLevel') 898 915 studylevel2.level = 200 … … 904 921 # The score of the carry-over course is now used for calculation of the 905 922 # GPA at level 100 ... 906 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[0], 4.0) 923 self.assertEqual( 924 self.student['studycourse']['100'].gpa_params_rectified[0], 4.0) 907 925 # ... but not at level 200 908 self.assertEqual(self.student['studycourse']['200'].gpa_params_rectified[0], 0.0) 926 self.assertEqual( 927 self.student['studycourse']['200'].gpa_params_rectified[0], 0.0) 909 928 return 910 929 … … 939 958 # self.browser.contents) 940 959 941 # The same payment (with same p_item, p_session and p_category) 942 # can be initialized a second time if the former ticket is not yet paid. 960 # The same payment (with same p_item, p_session and 961 # p_category) can be initialized a second time if the former 962 # ticket is not yet paid. 943 963 self.browser.open(self.payments_path) 944 964 self.browser.getLink("Add current session payment ticket").click() … … 957 977 # an access code is created after approval. 958 978 IWorkflowState(self.student).setState('school fee paid') 959 self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0)979 self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0) 960 980 self.browser.open(payment_url) 961 981 self.browser.getLink("Approve payment").click() 962 self.assertMatches( '...Payment approved...',963 982 self.assertMatches( 983 '...Payment approved...', self.browser.contents) 964 984 # Approval is logged in students.log ... 965 985 logcontent = open(logfile).read() … … 977 997 # The authorized amount has been stored in the new access code 978 998 self.assertEqual( 979 self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0)999 self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0) 980 1000 981 1001 # The catalog has been updated
Note: See TracChangeset for help on using the changeset viewer.