Changeset 13904 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 10 Jun 2016, 06:42:01 (9 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk
- Property svn:mergeinfo changed
/main/waeup.kofa/branches/uli-scores-upload (added) merged: 13902-13903
- Property svn:mergeinfo changed
-
main/waeup.kofa/trunk/src/waeup/kofa
- Property svn:mergeinfo changed
/main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa (added) merged: 13902-13903
- Property svn:mergeinfo changed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r13898 r13904 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 … … 41 41 from waeup.kofa.app import University 42 42 from waeup.kofa.payments.interfaces import IPayer 43 from waeup.kofa.students.interfaces import IStudentsUtils44 43 from waeup.kofa.students.student import Student 45 44 from waeup.kofa.students.studylevel import StudentStudyLevel … … 56 55 SAMPLE_IMAGE = os.path.join(os.path.dirname(__file__), 'test_image.jpg') 57 56 SAMPLE_IMAGE_BMP = os.path.join(os.path.dirname(__file__), 'test_image.bmp') 57 58 58 59 59 def lookup_submit_value(name, value, browser): … … 67 67 break 68 68 return None 69 69 70 70 71 class StudentsFullSetup(FunctionalTestCase): … … 180 181 self.app['faculties']['fac1']['dep1'].courses.addCourse( 181 182 self.course) 182 self.app['faculties']['fac1']['dep1'].certificates[ 'CERT1'].addCertCourse(183 self.course, level=100)183 self.app['faculties']['fac1']['dep1'].certificates[ 184 'CERT1'].addCertCourse(self.course, level=100) 184 185 185 186 # Configure university and hostels … … 239 240 240 241 241 242 242 class StudentsContainerUITests(StudentsFullSetup): 243 243 # Tests for StudentsContainer class views and pages … … 276 276 self.browser.getControl(name="form.reg_number").value = '123' 277 277 self.browser.getControl("Create student").click() 278 self.assertTrue( 'Registration number exists already'279 in self.browser.contents)278 self.assertTrue( 279 'Registration number exists already' in self.browser.contents) 280 280 self.browser.getControl(name="form.reg_number").value = '1234' 281 281 self.browser.getControl("Create student").click() … … 425 425 return 426 426 427 427 428 class OfficerUITests(StudentsFullSetup): 428 429 # Tests for Student class views and pages … … 441 442 studylevel.level = 100 442 443 cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1'] 443 self.student['studycourse'].addStudentStudyLevel( 444 cert,studylevel) 444 self.student['studycourse'].addStudentStudyLevel(cert, studylevel) 445 445 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 446 446 self.browser.open(self.studycourse_path + '/100/manage') 447 self.assertEqual(self.browser.url, self.studycourse_path + '/100/manage') 447 self.assertEqual( 448 self.browser.url, self.studycourse_path + '/100/manage') 448 449 self.assertEqual(self.browser.headers['Status'], '200 Ok') 449 450 … … 453 454 self.browser.getLink("Logout").click() 454 455 self.assertTrue('You have been logged out' in self.browser.contents) 455 # But we are still logged in since we've used basic authentication here. 456 # Wikipedia says: Existing browsers retain authentication information 457 # until the tab or browser is closed or the user clears the history. 458 # HTTP does not provide a method for a server to direct clients to 459 # discard these cached credentials. This means that there is no 460 # effective way for a server to "log out" the user without closing 461 # the browser. This is a significant defect that requires browser 462 # 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 ... 463 466 self.assertTrue('Manager' in self.browser.contents) 464 467 … … 571 574 self.browser.open(self.student_path) 572 575 self.browser.getLink("Send email").click() 573 self.browser.getControl(name="form.subject").value = 'Important subject' 576 self.browser.getControl( 577 name="form.subject").value = 'Important subject' 574 578 self.browser.getControl(name="form.body").value = 'Hello!' 575 579 self.browser.getControl("Send message now").click() 576 self.assertTrue('An smtp server error occurred' in self.browser.contents) 580 self.assertTrue( 581 'An smtp server error occurred' in self.browser.contents) 577 582 self.student.email = 'xx@yy.zz' 578 583 self.browser.getControl("Send message now").click() … … 623 628 file_ctrl.add_file(image, filename='my_birth_certificate.jpg') 624 629 # The Save action does not upload files 625 self.browser.getControl("Save").click() # submit form630 self.browser.getControl("Save").click() # submit form 626 631 self.assertFalse( 627 632 '<a target="image" href="birth_certificate">' … … 661 666 'Uploaded file is too big' in self.browser.contents) 662 667 # we do not rely on filename extensions given by uploaders 663 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file668 image = open(SAMPLE_IMAGE, 'rb') # a jpg-file 664 669 ctrl = self.browser.getControl(name='birthcertificateupload') 665 670 file_ctrl = ctrl.mech_control … … 682 687 self.browser.getControl( 683 688 name='upload_birthcertificateupload').click() 684 self.assertTrue('Only the following extensions are allowed' 689 self.assertTrue( 690 'Only the following extensions are allowed' 685 691 in self.browser.contents) 686 692 … … 693 699 self.browser.getControl( 694 700 name='upload_passportuploadmanage').click() 695 self.assertTrue( 'jpg file format expected'696 in self.browser.contents)701 self.assertTrue( 702 'jpg file format expected' in self.browser.contents) 697 703 ctrl = self.browser.getControl(name='passportuploadmanage') 698 704 file_ctrl = ctrl.mech_control … … 751 757 self.assertMatches('...<span>100</span>...', self.browser.contents) 752 758 self.assertEqual(self.student['studycourse']['100'].level, 100) 753 self.assertEqual(self.student['studycourse']['100'].level_session, 2004) 759 self.assertEqual( 760 self.student['studycourse']['100'].level_session, 2004) 754 761 self.browser.getControl(name="addlevel").value = ['100'] 755 762 self.browser.getControl(name="level_session").value = ['2004'] … … 767 774 self.app['datacenter'].storage, 'logs', 'students.log') 768 775 logcontent = open(logfile).read() 769 self.assertTrue('zope.mgr - students.browser.StudyCourseManageFormPage ' 770 '- K1000000 - removed: 100' in logcontent) 776 self.assertTrue( 777 'zope.mgr - students.browser.StudyCourseManageFormPage ' 778 '- K1000000 - removed: 100' in logcontent) 771 779 # Add level again 772 780 self.browser.getControl(name="addlevel").value = ['100'] … … 791 799 self.app['datacenter'].storage, 'logs', 'students.log') 792 800 logcontent = open(logfile).read() 793 self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage ' 794 '- K1000000 - removed: COURSE1 at 100' in logcontent) 801 self.assertTrue( 802 'zope.mgr - students.browser.StudyLevelManageFormPage ' 803 '- K1000000 - removed: COURSE1 at 100' in logcontent) 795 804 self.browser.getLink("here").click() 796 805 self.browser.getControl(name="form.course").value = ['COURSE1'] … … 824 833 self.assertTrue('Grade' in self.browser.contents) 825 834 self.assertTrue('Weight' in self.browser.contents) 826 self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C') 827 self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3) 828 # We add another ticket to check if GPA will be correctly calculated 829 # (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) 830 841 courseticket = createObject('waeup.CourseTicket') 831 842 courseticket.code = 'ANYCODE' … … 839 850 self.browser.open(self.student_path + '/studycourse/100') 840 851 # total credits 841 self.assertEqual(self.student['studycourse']['100'].gpa_params_rectified[1], 23) 852 self.assertEqual( 853 self.student['studycourse']['100'].gpa_params_rectified[1], 23) 842 854 # weigheted credits = 3 * 10 + 4 * 13 843 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) 844 857 # sgpa = 82 / 23 845 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) 846 860 # Carry-over courses will be collected when next level is created 847 861 self.browser.open(self.student_path + '/studycourse/manage') … … 891 905 studylevel['COURSE1'].score = studylevel['COURSE1'].passmark + 1 892 906 # GPA is 1. 893 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) 894 909 # Set score below passmark. 895 910 studylevel['COURSE1'].score = studylevel['COURSE1'].passmark - 1 896 911 # GPA is still 0. 897 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) 898 914 studylevel2 = createObject(u'waeup.StudentStudyLevel') 899 915 studylevel2.level = 200 … … 905 921 # The score of the carry-over course is now used for calculation of the 906 922 # GPA at level 100 ... 907 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) 908 925 # ... but not at level 200 909 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) 910 928 return 911 929 … … 940 958 # self.browser.contents) 941 959 942 # The same payment (with same p_item, p_session and p_category) 943 # 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. 944 963 self.browser.open(self.payments_path) 945 964 self.browser.getLink("Add current session payment ticket").click() … … 958 977 # an access code is created after approval. 959 978 IWorkflowState(self.student).setState('school fee paid') 960 self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0)979 self.assertEqual(len(self.app['accesscodes']['SFE-0']), 0) 961 980 self.browser.open(payment_url) 962 981 self.browser.getLink("Approve payment").click() 963 self.assertMatches( '...Payment approved...',964 982 self.assertMatches( 983 '...Payment approved...', self.browser.contents) 965 984 # Approval is logged in students.log ... 966 985 logcontent = open(logfile).read() … … 978 997 # The authorized amount has been stored in the new access code 979 998 self.assertEqual( 980 self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0)999 self.app['accesscodes']['SFE-0'].values()[0].cost, 40000.0) 981 1000 982 1001 # The catalog has been updated … … 1386 1405 IWorkflowState(self.student).setState('school fee paid') 1387 1406 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1388 student = self.app['students'][self.student_id]1389 1407 self.browser.open(self.trigtrans_path) 1390 1408 self.assertTrue('<option value="reset6">' in self.browser.contents) … … 3937 3955 # Thew job can be discarded 3938 3956 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 3939 #job_id = self.app['datacenter'].running_exports[0][0] 3940 job_id = self.wait_for_export_job_completed() 3957 self.wait_for_export_job_completed() 3941 3958 self.browser.open("http://localhost/app/faculties/fac1/dep1/exports") 3942 3959 self.browser.getControl("Discard").click() … … 3976 3993 # Thew job can be discarded 3977 3994 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 3978 #job_id = self.app['datacenter'].running_exports[0][0] 3979 job_id = self.wait_for_export_job_completed() 3995 self.wait_for_export_job_completed() 3980 3996 self.browser.open('http://localhost/app/faculties/exports') 3981 3997 self.browser.getControl("Discard").click()
Note: See TracChangeset for help on using the changeset viewer.