- Timestamp:
- 10 Sep 2012, 11:05:07 (12 years ago)
- Location:
- main/waeup.kofa/branches/uli-async-update
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-async-update
- Property svn:mergeinfo changed
-
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/sample_payment_data.csv
r8244 r9169 1 matric_number,p_state,p_category,p_id,reg_number,session_id,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type 2 ,paid,schoolfee,3816951290797973744#,1,2010,19500,BTECHBDT,19500,0942,00,2010/11/26 19:59:33.744 GMT+1,online 3 100001,unpaid,schoolfee,3816951290712593757,,2010,0,BTECHBDT,19500,0942,Z0,2010-11-25 20:16:33.757 GMT+1,online4 ,paid,schoolfee,p1266236341955,3,2009,19500,BTECHBDT,19500,0615,00,2010/02/15 13:19:01,online 1 matric_number,p_state,p_category,p_id,reg_number,session_id,r_amount_approved,p_item,amount_auth,r_card_num,r_code,creation_date,type,p_current 2 ,paid,schoolfee,3816951290797973744#,1,2010,19500,BTECHBDT,19500,0942,00,2010/11/26 19:59:33.744 GMT+1,online,1 3 100001,unpaid,schoolfee,3816951290712593757,,2010,0,BTECHBDT,19500,0942,Z0,2010-11-25 20:16:33.757 WAT,online,0 4 ,paid,schoolfee,p1266236341955,3,2009,19500,BTECHBDT,19500,0615,00,2010/02/15 13:19:01,online,1 -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_authentication.py
r8351 r9169 65 65 email = None 66 66 phone = None 67 suspended = False 67 68 68 69 -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_batching.py
r8626 r9169 23 23 import unittest 24 24 import datetime 25 import grok 25 26 from time import time 27 from zope.event import notify 26 28 from zope.component import createObject 27 29 from zope.component.hooks import setSite, clearSite 28 30 from zope.interface.verify import verifyClass, verifyObject 31 from hurry.workflow.interfaces import IWorkflowState 29 32 30 33 from waeup.kofa.app import University … … 126 129 '\n')[0].split(',') 127 130 131 PAYMENT_CREATE_SAMPLE_DATA = open( 132 os.path.join(os.path.dirname(__file__), 'sample_create_payment_data.csv'), 133 'rb').read() 134 135 PAYMENT_CREATE_HEADER_FIELDS = PAYMENT_CREATE_SAMPLE_DATA.split( 136 '\n')[0].split(',') 137 128 138 class StudentImportExportSetup(FunctionalTestCase): 129 139 … … 171 181 def setup_student(self, student): 172 182 # set predictable values for `student` 173 student.matric_number = u' M123456'183 student.matric_number = u'234' 174 184 student.adm_code = u'my adm code' 175 185 student.clearance_locked = False 176 186 student.clr_code = u'my clr code' 177 187 student.perm_address = u'Studentroad 21\nLagos 123456\n' 178 student.reg_number = u'123456' 179 student.student_id = u'A111111' 188 student.reg_number = u'123' 180 189 student.firstname = u'Anna' 181 190 student.lastname = u'Tester' … … 211 220 ticket.passmark = 100 212 221 ticket.semester = 2 213 study_level .addCourseTicket(ticket)222 study_level[ticket.code] = ticket 214 223 self.add_payment(student) 215 224 return student … … 232 241 233 242 234 235 class StudentProcessorTest(FunctionalTestCase): 243 class StudentProcessorTest(StudentImportExportSetup): 236 244 237 245 layer = FunctionalLayer … … 239 247 def setUp(self): 240 248 super(StudentProcessorTest, self).setUp() 241 # Setup a sample site for each test242 app = University()243 self.dc_root = tempfile.mkdtemp()244 app['datacenter'].setStoragePath(self.dc_root)245 246 # Prepopulate the ZODB...247 self.getRootFolder()['app'] = app248 # we add the site immediately after creation to the249 # ZODB. Catalogs and other local utilities are not setup250 # before that step.251 self.app = self.getRootFolder()['app']252 # Set site here. Some of the following setup code might need253 # to access grok.getSite() and should get our new app then254 setSite(app)255 249 256 250 # Add student with subobjects 257 251 student = Student() 258 student.firstname = u'Anna'259 student.lastname = u'Tester'260 student.reg_number = u'123'261 student.matric_number = u'234'262 252 self.app['students'].addStudent(student) 253 student = self.setup_student(student) 254 notify(grok.ObjectModifiedEvent(student)) 263 255 self.student = self.app['students'][student.student_id] 256 264 257 self.processor = StudentProcessor() 265 258 self.workdir = tempfile.mkdtemp() … … 285 278 open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES) 286 279 287 def tearDown(self):288 super(StudentProcessorTest, self).tearDown()289 shutil.rmtree(self.workdir)290 shutil.rmtree(self.dc_root)291 clearSite()292 return293 294 280 def test_interface(self): 295 281 # Make sure we fulfill the interface contracts. … … 343 329 self.assertEqual(initial_stud_id, new_stud_id) 344 330 return 331 332 def test_checkUpdateRequirements(self): 333 # Make sure that pg students can't be updated with wrong transition. 334 err = self.processor.checkUpdateRequirements(self.student, 335 dict(reg_number='1', state='returning'), self.app) 336 self.assertTrue(err is None) 337 self.certificate.study_mode = 'pg_ft' 338 err = self.processor.checkUpdateRequirements(self.student, 339 dict(reg_number='1', state='returning'), self.app) 340 self.assertEqual(err, 'State not allowed (pg student).') 341 IWorkflowState(self.student).setState('school fee paid') 342 err = self.processor.checkUpdateRequirements(self.student, 343 dict(reg_number='1', transition='reset6'), self.app) 344 self.assertEqual(err, 'Transition not allowed (pg student).') 345 err = self.processor.checkUpdateRequirements(self.student, 346 dict(reg_number='1', transition='register_courses'), self.app) 347 self.assertEqual(err, 'Transition not allowed (pg student).') 348 345 349 346 350 def test_delEntry(self): … … 486 490 super(StudentStudyCourseProcessorTest, self).setUp() 487 491 492 # Add student with subobjects 493 student = Student() 494 self.app['students'].addStudent(student) 495 student = self.setup_student(student) 496 notify(grok.ObjectModifiedEvent(student)) 497 self.student = self.app['students'][student.student_id] 498 488 499 # Import students with subobjects 489 500 student_file = os.path.join(self.workdir, 'sample_student_data.csv') … … 532 543 dict(reg_number='1', current_level='100')) 533 544 self.assertEqual(len(errs),0) 545 546 def test_checkUpdateRequirements(self): 547 # Make sure that pg students can't be updated with wrong transition. 548 err = self.processor.checkUpdateRequirements(self.student['studycourse'], 549 dict(reg_number='1', current_level='100'), self.app) 550 self.assertTrue(err is None) 551 # Since row has passed the converter, current_level is an integer. 552 err = self.processor.checkUpdateRequirements(self.student['studycourse'], 553 dict(reg_number='1', current_level=999), self.app) 554 self.assertTrue(err is None) 555 IWorkflowState(self.student).setState('returning') 556 err = self.processor.checkUpdateRequirements(self.student['studycourse'], 557 dict(reg_number='1', current_level=999), self.app) 558 self.assertEqual(err, 'Not a pg student.') 534 559 535 560 def test_import(self): … … 667 692 self.assertEqual(num_warns,2) 668 693 shutil.rmtree(os.path.dirname(fin_file)) 669 670 694 671 695 class CourseTicketProcessorTest(StudentImportExportSetup): … … 681 705 shutil.rmtree(os.path.dirname(fin_file)) 682 706 683 # Add course and c ourse referrer707 # Add course and certificate course 684 708 self.course = createObject('waeup.Course') 685 709 self.course.code = 'COURSE1' … … 689 713 self.app['faculties']['fac1']['dep1'].courses.addCourse( 690 714 self.course) 691 self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addC ourseRef(715 self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse( 692 716 self.course, level=100) 693 717 … … 755 779 # Logging message from updateEntry, 756 780 self.assertTrue( 757 'INFO - system - K1000000 - Course ticket updated: code=COURSE1, '781 'INFO - system - K1000000 - Course ticket in 100 updated: code=COURSE1, ' 758 782 'mandatory=False, score=3' 759 783 in logcontent) … … 769 793 self.assertEqual(num_warns,2) 770 794 shutil.rmtree(os.path.dirname(fin_file)) 795 796 def test_import_remove(self): 797 # We perform the same import twice, 798 # the second time in remove mode. The number 799 # of warnings must be the same. 800 num, num_warns, fin_file, fail_file = self.processor.doImport( 801 self.csv_file, COURSETICKET_HEADER_FIELDS,'create') 802 assert self.processor.entryExists( 803 dict(reg_number='1', level='100', code='COURSE1'), self.app) is True 804 num, num_warns, fin_file, fail_file = self.processor.doImport( 805 self.csv_file, COURSETICKET_HEADER_FIELDS,'remove') 806 self.assertEqual(num_warns,2) 807 assert self.processor.entryExists( 808 dict(reg_number='1', level='100', code='COURSE1'), self.app) is False 809 shutil.rmtree(os.path.dirname(fin_file)) 810 logcontent = open(self.logfile).read() 811 self.assertTrue( 812 'INFO - system - K1000000 - Course ticket in 100 removed: COURSE1' 813 in logcontent) 771 814 772 815 class PaymentProcessorTest(StudentImportExportSetup): … … 784 827 self.student = self.app['students'][student.student_id] 785 828 payment = createObject(u'waeup.StudentOnlinePayment') 786 payment.p_id = 'p12 3'829 payment.p_id = 'p120' 787 830 self.student['payments'][payment.p_id] = payment 788 831 … … 798 841 self.workdir, 'sample_payment_data.csv') 799 842 open(self.csv_file, 'wb').write(PAYMENT_SAMPLE_DATA) 843 self.csv_file2 = os.path.join( 844 self.workdir, 'sample_create_payment_data.csv') 845 open(self.csv_file2, 'wb').write(PAYMENT_CREATE_SAMPLE_DATA) 800 846 801 847 def test_interface(self): … … 809 855 dict(student_id='ID_NONE', p_id='nonsense'), self.app) is None 810 856 assert self.processor.getEntry( 811 dict(student_id=self.student.student_id, p_id='p12 3'),812 self.app) is self.student['payments']['p12 3']857 dict(student_id=self.student.student_id, p_id='p120'), 858 self.app) is self.student['payments']['p120'] 813 859 assert self.processor.getEntry( 814 dict(student_id=self.student.student_id, p_id='XXXXXX123'), 815 self.app) is self.student['payments']['p123'] 860 dict(student_id=self.student.student_id, p_id='XXXXXX112'), 861 self.app) is self.student['payments']['p120'] 862 863 def test_delEntry(self): 864 assert self.processor.getEntry( 865 dict(student_id=self.student.student_id, p_id='p120'), 866 self.app) is self.student['payments']['p120'] 867 self.assertEqual(len(self.student['payments'].keys()),1) 868 self.processor.delEntry( 869 dict(student_id=self.student.student_id, p_id='p120'), 870 self.app) 871 assert self.processor.getEntry( 872 dict(student_id=self.student.student_id, p_id='p120'), 873 self.app) is None 874 self.assertEqual(len(self.student['payments'].keys()),0) 816 875 817 876 def test_addEntry(self): … … 831 890 self.app) 832 891 self.assertEqual(len(self.student['payments'].keys()),3) 833 self.assertEqual(self.student['payments']['p 456'].p_id, 'p456')892 self.assertEqual(self.student['payments']['p560'].p_id, 'p560') 834 893 835 894 def test_checkConversion(self): 836 895 errs, inv_errs, conv_dict = self.processor.checkConversion( 837 dict( reg_number='1',p_id='3816951266236341955'))896 dict(p_id='3816951266236341955')) 838 897 self.assertEqual(len(errs),0) 839 898 errs, inv_errs, conv_dict = self.processor.checkConversion( 840 dict( reg_number='1',p_id='p1266236341955'))899 dict(p_id='p1266236341955')) 841 900 self.assertEqual(len(errs),0) 842 901 errs, inv_errs, conv_dict = self.processor.checkConversion( 843 dict( reg_number='1',p_id='nonsense'))902 dict(p_id='nonsense')) 844 903 self.assertEqual(len(errs),1) 845 timestamp = "%d" % int(time()*1000)904 timestamp = ("%d" % int(time()*10000))[1:] 846 905 p_id = "p%s" % timestamp 847 906 errs, inv_errs, conv_dict = self.processor.checkConversion( 848 dict( reg_number='1',p_id=p_id))907 dict(p_id=p_id)) 849 908 self.assertEqual(len(errs),0) 850 909 … … 854 913 self.assertEqual(num_warns,0) 855 914 payment = self.processor.getEntry(dict(reg_number='1', 856 p_id='p1290797973744'), self.app) 857 self.assertEqual(payment.p_id, 'p1290797973744') 915 p_id='p2907979737440'), self.app) 916 self.assertEqual(payment.p_id, 'p2907979737440') 917 self.assertTrue(payment.p_current) 858 918 cdate = payment.creation_date.strftime("%Y-%m-%d %H:%M:%S") 859 919 self.assertEqual(cdate, "2010-11-26 18:59:33") 860 920 self.assertEqual(str(payment.creation_date.tzinfo),'UTC') 861 shutil.rmtree(os.path.dirname(fin_file)) 862 921 payment = self.processor.getEntry(dict(matric_number='100001', 922 p_id='p2907125937570'), self.app) 923 self.assertEqual(payment.p_id, 'p2907125937570') 924 self.assertFalse(payment.p_current) 925 cdate = payment.creation_date.strftime("%Y-%m-%d %H:%M:%S") 926 # Ooooh, still the old problem, see 927 # http://mail.dzug.org/mailman/archives/zope/2006-August/001153.html. 928 # WAT is interpreted as GMT-1 and not GMT+1 929 self.assertEqual(cdate, "2010-11-25 21:16:33") 930 self.assertEqual(str(payment.creation_date.tzinfo),'UTC') 931 shutil.rmtree(os.path.dirname(fin_file)) 863 932 logcontent = open(self.logfile).read() 864 # Logging message from updateEntry ,933 # Logging message from updateEntry 865 934 self.assertTrue( 866 935 'INFO - system - K1000001 - Payment ticket updated: ' 867 'p_i d=p1266236341955, p_item=BTECHBDT, '868 ' creation_date=2010-02-15 13:19:01+00:00, r_code=00, '869 ' r_amount_approved=19500.0, p_category=schoolfee, '870 ' amount_auth=19500.0,p_state=paid'936 'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, ' 937 'p_category=schoolfee, amount_auth=19500.0, p_current=True, ' 938 'p_id=p1266236341955, r_code=00, r_amount_approved=19500.0, ' 939 'p_state=paid' 871 940 in logcontent) 872 941 … … 881 950 self.assertEqual(num_warns,0) 882 951 shutil.rmtree(os.path.dirname(fin_file)) 952 953 def test_import_remove(self): 954 num, num_warns, fin_file, fail_file = self.processor.doImport( 955 self.csv_file, PAYMENT_HEADER_FIELDS,'create') 956 num, num_warns, fin_file, fail_file = self.processor.doImport( 957 self.csv_file, PAYMENT_HEADER_FIELDS,'remove') 958 self.assertEqual(num_warns,0) 959 shutil.rmtree(os.path.dirname(fin_file)) 960 logcontent = open(self.logfile).read() 961 self.assertTrue( 962 'INFO - system - K1000001 - Payment ticket removed: p1266236341955' 963 in logcontent) 964 965 def test_import_wo_pid(self): 966 num, num_warns, fin_file, fail_file = self.processor.doImport( 967 self.csv_file2, PAYMENT_CREATE_HEADER_FIELDS,'create') 968 self.assertEqual(num_warns,0) 969 shutil.rmtree(os.path.dirname(fin_file)) 970 self.assertEqual(len(self.app['students']['X666666']['payments']), 50) 971 883 972 884 973 def test_suite(): -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_browser.py
r8779 r9169 118 118 self.manage_clearance_path = self.student_path + '/manage_clearance' 119 119 self.edit_personal_path = self.student_path + '/edit_personal' 120 self.manage_personal_path = self.student_path + '/manage_personal' 120 121 self.studycourse_path = self.student_path + '/studycourse' 121 122 self.payments_path = self.student_path + '/payments' … … 170 171 self.app['faculties']['fac1']['dep1'].courses.addCourse( 171 172 self.course) 172 self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addC ourseRef(173 self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse( 173 174 self.course, level=100) 174 175 … … 454 455 self.assertEqual(self.browser.headers['Status'], '200 Ok') 455 456 self.assertEqual(self.browser.url, self.personal_path) 457 self.browser.getLink("Manage").click() 458 self.assertEqual(self.browser.headers['Status'], '200 Ok') 459 self.assertEqual(self.browser.url, self.manage_personal_path) 460 self.browser.open(self.personal_path) 456 461 self.browser.getLink("Edit").click() 457 462 self.assertEqual(self.browser.headers['Status'], '200 Ok') … … 474 479 self.assertEqual(self.browser.headers['Status'], '200 Ok') 475 480 self.assertEqual(self.browser.url, self.history_path) 476 self.assertMatches('... Student admitted by Manager...',481 self.assertMatches('...Admitted by Manager...', 477 482 self.browser.contents) 478 483 # Only the Application Slip does not exist … … 754 759 self.assertEqual(student['studycourse'].current_session, 2005) # +1 755 760 self.assertEqual(student['studycourse'].current_level, 200) # +100 756 self.assertEqual(student['studycourse'].current_verdict, ' NY') # NY= not set761 self.assertEqual(student['studycourse'].current_verdict, '0') # 0 = Zero = not set 757 762 self.assertEqual(student['studycourse'].previous_verdict, 'A') 758 763 self.browser.getControl(name="transition").value = ['register_courses'] … … 762 767 self.browser.getControl(name="transition").value = ['return'] 763 768 self.browser.getControl("Save").click() 769 return 770 771 def test_manage_pg_workflow(self): 772 # Managers can pass through the whole workflow 773 IWorkflowState(self.student).setState('school fee paid') 774 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 775 student = self.app['students'][self.student_id] 776 self.browser.open(self.manage_student_path) 777 self.assertTrue('<option value="reset6">' in self.browser.contents) 778 self.assertTrue('<option value="register_courses">' in self.browser.contents) 779 self.assertTrue('<option value="reset5">' in self.browser.contents) 780 self.certificate.study_mode = 'pg_ft' 781 self.browser.open(self.manage_student_path) 782 self.assertFalse('<option value="reset6">' in self.browser.contents) 783 self.assertFalse('<option value="register_courses">' in self.browser.contents) 784 self.assertTrue('<option value="reset5">' in self.browser.contents) 764 785 return 765 786 … … 776 797 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 777 798 self.browser.open(datacenter_path) 778 self.browser.getLink('Upload CSV file').click()799 self.browser.getLink('Upload data').click() 779 800 filecontents = StringIO(open('students.csv', 'rb').read()) 780 801 filewidget = self.browser.getControl(name='uploadfile:file') 781 802 filewidget.add_file(filecontents, 'text/plain', 'students.csv') 782 803 self.browser.getControl(name='SUBMIT').click() 783 self.browser.getLink(' Batch processing').click()804 self.browser.getLink('Process data').click() 784 805 button = lookup_submit_value( 785 806 'select', 'students_zope.mgr.csv', self.browser) … … 802 823 """) 803 824 self.browser.open(datacenter_path) 804 self.browser.getLink('Upload CSV file').click()825 self.browser.getLink('Upload data').click() 805 826 filecontents = StringIO(open('studycourses.csv', 'rb').read()) 806 827 filewidget = self.browser.getControl(name='uploadfile:file') 807 828 filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv') 808 829 self.browser.getControl(name='SUBMIT').click() 809 self.browser.getLink(' Batch processing').click()830 self.browser.getLink('Process data').click() 810 831 button = lookup_submit_value( 811 832 'select', 'studycourses_zope.mgr.csv', self.browser) … … 917 938 self.assertTrue('clearance started' in self.browser.contents) 918 939 self.browser.open(self.history_path) 919 self.assertTrue("Reset to 'clearance ' by My Public Name" in940 self.assertTrue("Reset to 'clearance started' by My Public Name" in 920 941 self.browser.contents) 921 942 IWorkflowInfo(self.student).fireTransition('request_clearance') … … 946 967 self.app['users'].addUser('mrsadvise', 'mrsadvisesecret') 947 968 self.app['users']['mrsadvise'].email = 'mradvise@foo.ng' 948 self.app['users']['mrsadvise'].title = 'Helen Procter'969 self.app['users']['mrsadvise'].title = u'Helen Procter' 949 970 # Assign local CourseAdviser100 role for a certificate 950 971 cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1'] … … 997 1018 # the 100L CA does see the 'Validate' button 998 1019 self.browser.open(L110_student_path) 999 self.assertFalse('Validate ' in self.browser.contents)1020 self.assertFalse('Validate courses' in self.browser.contents) 1000 1021 IWorkflowInfo(self.student).fireTransition('register_courses') 1001 1022 self.browser.open(L110_student_path) 1002 self.assertFalse('Validate ' in self.browser.contents)1023 self.assertFalse('Validate courses' in self.browser.contents) 1003 1024 self.student['studycourse'].current_level = 110 1004 1025 self.browser.open(L110_student_path) 1005 self.assertTrue('Validate ' in self.browser.contents)1026 self.assertTrue('Validate courses' in self.browser.contents) 1006 1027 # ... but a 100L CA does not see the button on other levels 1007 1028 studylevel2 = StudentStudyLevel() … … 1011 1032 L200_student_path = self.studycourse_path + '/200' 1012 1033 self.browser.open(L200_student_path) 1013 self.assertFalse('Validate ' in self.browser.contents)1034 self.assertFalse('Validate courses' in self.browser.contents) 1014 1035 self.browser.open(L110_student_path) 1015 1036 self.browser.getLink("Validate courses").click() 1016 1037 self.assertTrue('Course list has been validated' in self.browser.contents) 1017 1038 self.assertTrue('courses validated' in self.browser.contents) 1039 self.assertEqual(self.student['studycourse']['110'].validated_by, 1040 'Helen Procter') 1041 self.assertMatches( 1042 '<YYYY-MM-DD hh:mm:ss>', 1043 self.student['studycourse']['110'].validation_date.strftime( 1044 "%Y-%m-%d %H:%M:%S")) 1018 1045 self.browser.getLink("Reject courses").click() 1019 1046 self.assertTrue('Course list request has been annulled.' … … 1023 1050 '/contactstudent?subject=%s' % urlmessage) 1024 1051 self.assertTrue('school fee paid' in self.browser.contents) 1052 self.assertTrue(self.student['studycourse']['110'].validated_by is None) 1053 self.assertTrue(self.student['studycourse']['110'].validation_date is None) 1025 1054 IWorkflowInfo(self.student).fireTransition('register_courses') 1026 1055 self.browser.open(L110_student_path) … … 1142 1171 # and can perform actions 1143 1172 IWorkflowInfo(self.student).fireTransition('admit') 1173 # Students can't login if their account is suspended/deactivated 1174 self.student.suspended = True 1144 1175 self.browser.open(self.login_path) 1145 1176 self.browser.getControl(name="form.login").value = self.student_id 1146 1177 self.browser.getControl(name="form.password").value = 'spwd' 1147 1178 self.browser.getControl("Login").click() 1179 self.assertTrue( 1180 'Your account has been deactivated.' in self.browser.contents) 1181 self.student.suspended = False 1182 self.browser.getControl("Login").click() 1183 self.assertTrue( 1184 'You logged in.' in self.browser.contents) 1148 1185 # Student can upload a passport picture 1149 1186 self.browser.open(self.student_path + '/change_portrait') … … 1170 1207 self.assertMatches('...Not all required fields filled...', 1171 1208 self.browser.contents) 1172 self.student.email = 'aa@aa.ng' 1209 self.browser.open(self.student_path + '/edit_base') 1210 self.browser.getControl(name="form.email").value = 'aa@aa.ng' 1211 self.browser.getControl("Save").click() 1173 1212 self.browser.open(self.student_path + '/start_clearance') 1174 1213 self.browser.getControl(name="ac_series").value = '3' … … 1185 1224 # Set the correct owner 1186 1225 self.existing_clrac.owner = self.student_id 1226 # clr_code might be set (and thus returns None) due importing 1227 # an empty clr_code column. 1228 self.student.clr_code = None 1187 1229 self.browser.getControl("Start clearance now").click() 1188 1230 self.assertMatches('...Clearance process has been started...', … … 1235 1277 self.browser.getControl("Create course list now").click() 1236 1278 self.browser.getLink("100").click() 1237 self.browser.getLink(" Add and remove courses").click()1279 self.browser.getLink("Edit course list").click() 1238 1280 self.browser.getControl("Add course ticket").click() 1239 1281 self.browser.getControl(name="form.course").value = ['COURSE1'] … … 1248 1290 self.browser.getControl("Create course list now").click() 1249 1291 self.browser.getLink("200").click() 1250 self.browser.getLink(" Add and remove courses").click()1292 self.browser.getLink("Edit course list").click() 1251 1293 self.browser.getControl("Add course ticket").click() 1252 1294 self.browser.getControl(name="form.course").value = ['COURSE1'] … … 1286 1328 self.assertEqual(self.student.state, 'courses registered') 1287 1329 return 1330 1331 def test_student_clearance_wo_clrcode(self): 1332 IWorkflowState(self.student).setState('clearance started') 1333 self.browser.open(self.login_path) 1334 self.browser.getControl(name="form.login").value = self.student_id 1335 self.browser.getControl(name="form.password").value = 'spwd' 1336 self.browser.getControl("Login").click() 1337 self.student.clearance_locked = False 1338 self.browser.open(self.edit_clearance_path) 1339 self.browser.getControl(name="form.date_of_birth").value = '09/10/1961' 1340 self.browser.getControl("Save and request clearance").click() 1341 self.assertMatches('...Clearance has been requested...', 1342 self.browser.contents) 1288 1343 1289 1344 def test_manage_payments(self): … … 1516 1571 # The new SFE-0 pin can be used for starting new session 1517 1572 self.browser.open(self.studycourse_path) 1518 self.browser.getLink('Start session').click()1573 self.browser.getLink('Start new session').click() 1519 1574 pin = self.app['accesscodes']['SFE-0'].keys()[0] 1520 1575 parts = pin.split('-')[1:] … … 1528 1583 return 1529 1584 1530 def test_postgraduate_payments(self): 1585 def test_student_previous_payments(self): 1586 # Login 1587 self.browser.open(self.login_path) 1588 self.browser.getControl(name="form.login").value = self.student_id 1589 self.browser.getControl(name="form.password").value = 'spwd' 1590 self.browser.getControl("Login").click() 1591 1592 # Students can add previous school fee payment tickets in any state. 1593 IWorkflowState(self.student).setState('courses registered') 1594 self.browser.open(self.payments_path) 1595 self.browser.getControl("Add online payment ticket").click() 1596 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1597 self.browser.getControl("Create ticket").click() 1598 1599 # Amount cannot be determined since the state is not 1600 # 'cleared' or 'returning' 1601 self.assertMatches('...Amount could not be determined...', 1602 self.browser.contents) 1603 self.assertMatches('...Would you like to pay for a previous session?...', 1604 self.browser.contents) 1605 1606 # Previous session payment form is provided 1607 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1608 self.browser.getControl(name="form.p_session").value = ['2004'] 1609 self.browser.getControl(name="form.p_level").value = ['300'] 1610 self.browser.getControl("Create ticket").click() 1611 self.assertMatches('...ticket created...', 1612 self.browser.contents) 1613 ctrl = self.browser.getControl(name='val_id') 1614 value = ctrl.options[0] 1615 self.browser.getLink(value).click() 1616 self.assertMatches('...Amount Authorized...', 1617 self.browser.contents) 1618 self.assertEqual(self.student['payments'][value].amount_auth, 20000.0) 1619 1620 # Payment session is properly set 1621 self.assertEqual(self.student['payments'][value].p_session, 2004) 1622 self.assertEqual(self.student['payments'][value].p_level, 300) 1623 1624 # We simulate the approval 1625 self.browser.open(self.browser.url + '/fake_approve') 1626 self.assertMatches('...Payment approved...', 1627 self.browser.contents) 1628 1629 # No AC has been created 1630 self.assertEqual(len(self.app['accesscodes']['SFE-0'].keys()), 0) 1631 self.assertTrue(self.student['payments'][value].ac is None) 1632 1633 # Current payment flag is set False 1634 self.assertFalse(self.student['payments'][value].p_current) 1635 return 1636 1637 def test_student_postgraduate_payments(self): 1531 1638 self.certificate.study_mode = 'pg_ft' 1532 1639 self.certificate.start_level = 999 … … 1552 1659 self.browser.contents) 1553 1660 # Payment session and level are current ones. 1554 # Postgrads have to school_fee_1.1661 # Postgrads have to pay school_fee_1. 1555 1662 self.assertEqual(self.student['payments'][value].amount_auth, 40000.0) 1556 1663 self.assertEqual(self.student['payments'][value].p_session, 2004) … … 1565 1672 # The new SFE-0 pin can be used for starting session 1566 1673 self.browser.open(self.studycourse_path) 1567 self.browser.getLink('Start session').click()1674 self.browser.getLink('Start new session').click() 1568 1675 pin = self.app['accesscodes']['SFE-0'].keys()[0] 1569 1676 parts = pin.split('-')[1:] … … 1605 1712 # The new SFE-1 pin can be used for starting new session 1606 1713 self.browser.open(self.studycourse_path) 1607 self.browser.getLink('Start session').click()1714 self.browser.getLink('Start new session').click() 1608 1715 self.browser.getControl(name="ac_series").value = sfeseries 1609 1716 self.browser.getControl(name="ac_number").value = sfenumber … … 1850 1957 self.assertTrue('An email with' in self.browser.contents) 1851 1958 1852 def test_reindex(self):1853 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')1854 self.browser.open('http://localhost/app/reindex')1855 self.assertTrue('No catalog name provided' in self.browser.contents)1856 self.browser.open('http://localhost/app/reindex?ctlg=xyz')1857 self.assertTrue('xyz_catalog does not exist' in self.browser.contents)1858 cat = queryUtility(ICatalog, name='students_catalog')1859 results = cat.searchResults(student_id=(None, None))1860 self.assertEqual(len(results),1)1861 cat.clear()1862 results = cat.searchResults(student_id=(None, None))1863 self.assertEqual(len(results),0)1864 self.browser.open('http://localhost/app/reindex?ctlg=students')1865 self.assertTrue('1 students re-indexed' in self.browser.contents)1866 results = cat.searchResults(student_id=(None, None))1867 self.assertEqual(len(results),1)1868 1869 1959 def test_change_current_mode(self): 1870 1960 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 1888 1978 self.assertTrue('Employer' in self.browser.contents) 1889 1979 1980 def test_activate_deactivate_buttons(self): 1981 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1982 self.browser.open(self.student_path) 1983 self.browser.getLink("Deactivate").click() 1984 self.assertTrue( 1985 'Student account has been deactivated.' in self.browser.contents) 1986 self.assertTrue( 1987 'Base Data (account deactivated)' in self.browser.contents) 1988 self.assertTrue(self.student.suspended) 1989 self.browser.getLink("Activate").click() 1990 self.assertTrue( 1991 'Student account has been activated.' in self.browser.contents) 1992 self.assertFalse( 1993 'Base Data (account deactivated)' in self.browser.contents) 1994 self.assertFalse(self.student.suspended) 1995 # History messages have been added ... 1996 self.browser.getLink("History").click() 1997 self.assertTrue( 1998 'Student account deactivated by Manager<br />' in self.browser.contents) 1999 self.assertTrue( 2000 'Student account activated by Manager<br />' in self.browser.contents) 2001 # ... and actions have been logged. 2002 logfile = os.path.join( 2003 self.app['datacenter'].storage, 'logs', 'students.log') 2004 logcontent = open(logfile).read() 2005 self.assertTrue('zope.mgr - students.browser.StudentDeactivatePage - ' 2006 'K1000000 - account deactivated' in logcontent) 2007 self.assertTrue('zope.mgr - students.browser.StudentActivatePage - ' 2008 'K1000000 - account activated' in logcontent) 2009 2010 def test_student_transfer(self): 2011 # Add second certificate 2012 self.certificate2 = createObject('waeup.Certificate') 2013 self.certificate2.code = u'CERT2' 2014 self.certificate2.study_mode = 'ug_ft' 2015 self.certificate2.start_level = 999 2016 self.certificate2.end_level = 999 2017 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 2018 self.certificate2) 2019 2020 # Add study level to old study course 2021 studylevel = createObject(u'waeup.StudentStudyLevel') 2022 studylevel.level = 200 2023 self.student['studycourse'].addStudentStudyLevel( 2024 self.certificate, studylevel) 2025 2026 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2027 self.browser.open(self.student_path) 2028 self.browser.getLink("Transfer").click() 2029 self.browser.getControl(name="form.certificate").value = ['CERT2'] 2030 self.browser.getControl(name="form.current_session").value = ['2011'] 2031 self.browser.getControl(name="form.current_level").value = ['200'] 2032 self.browser.getControl("Transfer").click() 2033 self.assertTrue( 2034 'Current level does not match certificate levels' 2035 in self.browser.contents) 2036 self.browser.getControl(name="form.current_level").value = ['999'] 2037 self.browser.getControl("Transfer").click() 2038 self.assertTrue('Successfully transferred' in self.browser.contents) 2039 2040 # Add study level to new study course 2041 studylevel = createObject(u'waeup.StudentStudyLevel') 2042 studylevel.level = 200 2043 self.student['studycourse'].addStudentStudyLevel( 2044 self.certificate, studylevel) 2045 2046 # Edit and add pages are locked for old study courses 2047 self.browser.open(self.student_path + '/studycourse/manage') 2048 self.assertFalse('The requested form is locked' in self.browser.contents) 2049 self.browser.open(self.student_path + '/studycourse_1/manage') 2050 self.assertTrue('The requested form is locked' in self.browser.contents) 2051 2052 self.browser.open(self.student_path + '/studycourse/start_session') 2053 self.assertFalse('The requested form is locked' in self.browser.contents) 2054 self.browser.open(self.student_path + '/studycourse_1/start_session') 2055 self.assertTrue('The requested form is locked' in self.browser.contents) 2056 2057 IWorkflowState(self.student).setState('school fee paid') 2058 self.browser.open(self.student_path + '/studycourse/add') 2059 self.assertFalse('The requested form is locked' in self.browser.contents) 2060 self.browser.open(self.student_path + '/studycourse_1/add') 2061 self.assertTrue('The requested form is locked' in self.browser.contents) 2062 2063 self.browser.open(self.student_path + '/studycourse/200/manage') 2064 self.assertFalse('The requested form is locked' in self.browser.contents) 2065 self.browser.open(self.student_path + '/studycourse_1/200/manage') 2066 self.assertTrue('The requested form is locked' in self.browser.contents) 2067 2068 self.browser.open(self.student_path + '/studycourse/200/validate_courses') 2069 self.assertFalse('The requested form is locked' in self.browser.contents) 2070 self.browser.open(self.student_path + '/studycourse_1/200/validate_courses') 2071 self.assertTrue('The requested form is locked' in self.browser.contents) 2072 2073 self.browser.open(self.student_path + '/studycourse/200/reject_courses') 2074 self.assertFalse('The requested form is locked' in self.browser.contents) 2075 self.browser.open(self.student_path + '/studycourse_1/200/reject_courses') 2076 self.assertTrue('The requested form is locked' in self.browser.contents) 2077 2078 self.browser.open(self.student_path + '/studycourse/200/add') 2079 self.assertFalse('The requested form is locked' in self.browser.contents) 2080 self.browser.open(self.student_path + '/studycourse_1/200/add') 2081 self.assertTrue('The requested form is locked' in self.browser.contents) 2082 2083 self.browser.open(self.student_path + '/studycourse/200/edit') 2084 self.assertFalse('The requested form is locked' in self.browser.contents) 2085 self.browser.open(self.student_path + '/studycourse_1/200/edit') 2086 self.assertTrue('The requested form is locked' in self.browser.contents) 2087 1890 2088 class StudentRequestPWTests(StudentsFullSetup): 1891 2089 # Tests for student registration … … 1894 2092 1895 2093 def test_request_pw(self): 1896 # Student with wrong reg_number can't be found.2094 # Student with wrong number can't be found. 1897 2095 self.browser.open('http://localhost/app/requestpw') 1898 2096 self.browser.getControl(name="form.firstname").value = 'Anna' 1899 self.browser.getControl(name="form. reg_number").value = 'anynumber'2097 self.browser.getControl(name="form.number").value = 'anynumber' 1900 2098 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 1901 self.browser.getControl(" Getlogin credentials").click()2099 self.browser.getControl("Send login credentials").click() 1902 2100 self.assertTrue('No student record found.' 1903 2101 in self.browser.contents) … … 1906 2104 self.browser.open('http://localhost/app/requestpw') 1907 2105 self.browser.getControl(name="form.firstname").value = 'Johnny' 1908 self.browser.getControl(name="form. reg_number").value = '123'2106 self.browser.getControl(name="form.number").value = '123' 1909 2107 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 1910 self.browser.getControl(" Getlogin credentials").click()2108 self.browser.getControl("Send login credentials").click() 1911 2109 self.assertTrue('No student record found.' 1912 2110 in self.browser.contents) … … 1914 2112 # password has been set and used. 1915 2113 self.browser.getControl(name="form.firstname").value = 'Anna' 1916 self.browser.getControl(name="form. reg_number").value = '123'1917 self.browser.getControl(" Getlogin credentials").click()2114 self.browser.getControl(name="form.number").value = '123' 2115 self.browser.getControl("Send login credentials").click() 1918 2116 self.assertTrue('Your password has already been set and used.' 1919 2117 in self.browser.contents) … … 1922 2120 # The firstname field, used for verification, is not case-sensitive. 1923 2121 self.browser.getControl(name="form.firstname").value = 'aNNa' 1924 self.browser.getControl(name="form. reg_number").value = '123'2122 self.browser.getControl(name="form.number").value = '123' 1925 2123 self.browser.getControl(name="form.email").value = 'new@yy.zz' 1926 self.browser.getControl(" Getlogin credentials").click()2124 self.browser.getControl("Send login credentials").click() 1927 2125 # Yeah, we succeded ... 2126 self.assertTrue('Your password request was successful.' 2127 in self.browser.contents) 2128 # We can also use the matric_number instead. 2129 self.browser.open('http://localhost/app/requestpw') 2130 self.browser.getControl(name="form.firstname").value = 'aNNa' 2131 self.browser.getControl(name="form.number").value = '234' 2132 self.browser.getControl(name="form.email").value = 'new@yy.zz' 2133 self.browser.getControl("Send login credentials").click() 1928 2134 self.assertTrue('Your password request was successful.' 1929 2135 in self.browser.contents) … … 1934 2140 email=('new@yy.zz', 'new@yy.zz'))) 1935 2141 self.assertEqual(self.student,results[0]) 2142 logfile = os.path.join( 2143 self.app['datacenter'].storage, 'logs', 'main.log') 2144 logcontent = open(logfile).read() 2145 self.assertTrue('zope.anybody - students.browser.StudentRequestPasswordPage - ' 2146 '234 (K1000000) - new@yy.zz' in logcontent) 1936 2147 return -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_dynamicroles.py
r7811 r9169 25 25 Test as APRMTest, Manageable) 26 26 from waeup.kofa.testing import FunctionalLayer 27 from waeup.kofa.app import University 27 28 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 28 29 from waeup.kofa.students import Student, StudentPrincipalRoleManager … … 48 49 def setUp(self): 49 50 super(StudentPrincipalRoleManagerFunctionalTests, self).setUp() 50 self.officer_role = 'waeup.StudentsClearanceOfficer'51 51 # assign clearance permissions for a virtual officer 52 52 prm = IPrincipalRoleManager(self.app['faculties']['fac1']['dep1']) 53 53 prm.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'alice') 54 prm.assignRoleToPrincipal('waeup.local.PGClearanceOfficer', 'bob') 55 prm.assignRoleToPrincipal('waeup.local.UGClearanceOfficer', 'anne') 54 56 return 55 57 … … 74 76 # student 75 77 prm = IPrincipalRoleManager(self.student) 76 result = prm.getRolesForPrincipal(' bob')78 result = prm.getRolesForPrincipal('claus') 77 79 self.assertEqual(result, []) 78 80 return … … 83 85 prm = IPrincipalRoleManager(self.student) 84 86 result = prm.getRolesForPrincipal('alice') 85 self.assertEqual(result, [(self.officer_role, Allow)]) 87 self.assertEqual(result, [('waeup.StudentsClearanceOfficer', Allow)]) 88 # Student is a UG student 89 self.assertFalse(self.student.is_postgrad) 90 result = prm.getRolesForPrincipal('bob') 91 self.assertEqual(result, [('waeup.StudentsOfficer', Allow)]) 92 result = prm.getRolesForPrincipal('anne') 93 self.assertEqual(result, [('waeup.StudentsClearanceOfficer', Allow)]) 94 # Make student a PG student 95 self.certificate.study_mode = u'pg_ft' 96 self.assertTrue(self.student.is_postgrad) 97 result = prm.getRolesForPrincipal('bob') 98 # The dynamic roles changed 99 self.assertEqual(result, [('waeup.StudentsClearanceOfficer', Allow)]) 100 result = prm.getRolesForPrincipal('anne') 101 self.assertEqual(result, [('waeup.StudentsOfficer', Allow)]) 86 102 return -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_export.py
r8621 r9169 44 44 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 45 45 'firstname,lastname,matric_number,middlename,nationality,' 46 'perm_address,phone,reg_number,sex,student_id, password,'46 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 47 47 'state,history,certcode\r\n' 48 48 49 49 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 50 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'51 '+234-123-12345 ,123456,f,A111111,,created'50 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 51 '+234-123-12345#,123,f,A111111,0,,created' 52 52 in result 53 53 ) … … 64 64 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 65 65 'firstname,lastname,matric_number,middlename,nationality,' 66 'perm_address,phone,reg_number,sex,student_id, password,'66 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 67 67 'state,history,certcode\r\n' 68 68 69 69 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 70 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'71 '+234-123-12345 ,123456,f,A111111,,created'70 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 71 '+234-123-12345#,123,f,A111111,0,,created' 72 72 in result 73 73 ) … … 83 83 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 84 84 'firstname,lastname,matric_number,middlename,nationality,' 85 'perm_address,phone,reg_number,sex,student_id, password,'85 'perm_address,phone,reg_number,sex,student_id,suspended,password,' 86 86 'state,history,certcode\r\n' 87 87 88 88 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 89 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'90 '+234-123-12345 ,123456,f,A111111,,created'89 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 90 '+234-123-12345#,123,f,A111111,0,,created' 91 91 in result 92 92 ) … … 127 127 'entry_mode,entry_session,previous_verdict,student_id\r\n' 128 128 129 ',,, NY,,,NY,\r\n'129 ',,,0,,,0,\r\n' 130 130 ) 131 131 return … … 144 144 'entry_mode,entry_session,previous_verdict,student_id\r\n' 145 145 146 'CERT1,200,2012, NY,ug_ft,2010,NY,A111111\r\n'146 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' 147 147 ) 148 148 return … … 160 160 'entry_mode,entry_session,previous_verdict,student_id\r\n' 161 161 162 'CERT1,200,2012, NY,ug_ft,2010,NY,A111111\r\n'162 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' 163 163 ) 164 164 return … … 175 175 'entry_mode,entry_session,previous_verdict,student_id\r\n' 176 176 177 'CERT1,200,2012, NY,ug_ft,2010,NY,A111111\r\n'177 'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n' 178 178 ) 179 179 return … … 209 209 self.assertEqual( 210 210 result, 211 'level,level_session,level_verdict,student_id\r\n' 212 ',,NY,\r\n' 211 'level,level_session,level_verdict,validated_by,validation_date,' 212 'student_id\r\n' 213 ',,0,,,\r\n' 213 214 ) 214 215 return … … 225 226 self.assertEqual( 226 227 result, 227 'level,level_session,level_verdict,student_id\r\n' 228 '100,2012,A,A111111\r\n' 228 'level,level_session,level_verdict,validated_by,validation_date,' 229 'student_id\r\n' 230 '100,2012,A,,,A111111\r\n' 229 231 ) 230 232 return … … 239 241 self.assertEqual( 240 242 result, 241 'level,level_session,level_verdict,student_id\r\n' 242 '100,2012,A,A111111\r\n' 243 'level,level_session,level_verdict,validated_by,validation_date,' 244 'student_id\r\n' 245 '100,2012,A,,,A111111\r\n' 243 246 ) 244 247 return … … 252 255 self.assertEqual( 253 256 result, 254 'level,level_session,level_verdict,student_id\r\n' 255 '100,2012,A,A111111\r\n' 257 'level,level_session,level_verdict,validated_by,validation_date,' 258 'student_id\r\n' 259 '100,2012,A,,,A111111\r\n' 256 260 ) 257 261 return … … 371 375 self.assertEqual( 372 376 result, 373 'ac,amount_auth,creation_date,p_category,p_ id,'377 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 374 378 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 375 379 'r_code,r_desc,student_id\r\n' 376 380 377 ',0.0,2012-04-01 13:12:01,schoolfee, ,,,,unpaid,,0.0,,,\r\n'381 ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,\r\n' 378 382 ) 379 383 return … … 389 393 self.assertEqual( 390 394 result, 391 'ac,amount_auth,creation_date,p_category,p_ id,'395 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 392 396 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 393 397 'r_code,r_desc,student_id\r\n' 394 398 395 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'399 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 396 400 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 397 401 'r-code,,A111111\r\n' … … 408 412 self.assertEqual( 409 413 result, 410 'ac,amount_auth,creation_date,p_category,p_ id,'414 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 411 415 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 412 416 'r_code,r_desc,student_id\r\n' 413 417 414 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'418 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 415 419 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 416 420 'r-code,,A111111\r\n' … … 427 431 self.assertEqual( 428 432 result, 429 'ac,amount_auth,creation_date,p_category,p_ id,'433 'ac,amount_auth,creation_date,p_category,p_current,p_id,' 430 434 'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,' 431 435 'r_code,r_desc,student_id\r\n' 432 436 433 '666,0.0,2012-04-01 13:12:01,schoolfee, my-id,'437 '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,' 434 438 'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,' 435 439 'r-code,,A111111\r\n' -
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/students/tests/test_student.py
r8735 r9169 21 21 import re 22 22 import unittest 23 import grok 23 24 from cStringIO import StringIO 24 25 from datetime import tzinfo 25 from zope.component import getUtility 26 from zope.component import getUtility, queryUtility, createObject 27 from zope.catalog.interfaces import ICatalog 26 28 from zope.component.interfaces import IFactory 29 from zope.event import notify 27 30 from zope.interface import verify 31 from zope.schema.interfaces import RequiredMissing 28 32 from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser 29 33 from waeup.kofa.students.export import EXPORTER_NAMES … … 129 133 studylevel = StudentStudyLevel() 130 134 self.assertRaises( 131 TypeError, studylevel.addCourseTicket, department )135 TypeError, studylevel.addCourseTicket, department, department) 132 136 133 137 def test_booking_date(self): … … 236 240 return 237 241 242 class StudentTransferTests(StudentImportExportSetup): 243 244 layer = FunctionalLayer 245 246 def setUp(self): 247 super(StudentTransferTests, self).setUp() 248 249 # Add additional certificate 250 self.certificate2 = createObject('waeup.Certificate') 251 self.certificate2.code = 'CERT2' 252 self.certificate2.application_category = 'basic' 253 self.certificate2.start_level = 200 254 self.certificate2.end_level = 500 255 self.app['faculties']['fac1']['dep1'].certificates.addCertificate( 256 self.certificate2) 257 258 # Add student with subobjects 259 student = Student() 260 self.app['students'].addStudent(student) 261 student = self.setup_student(student) 262 notify(grok.ObjectModifiedEvent(student)) 263 self.student = self.app['students'][student.student_id] 264 return 265 266 def test_transfer_student(self): 267 self.assertRaises( 268 RequiredMissing, self.student.transfer, self.certificate2) 269 error = self.student.transfer(self.certificate2, current_session=1000) 270 self.assertTrue(error == -1) 271 error = self.student.transfer(self.certificate2, current_session=2013) 272 self.assertTrue(error == None) 273 self.assertEqual(self.student['studycourse_1'].certificate.code, 'CERT1') 274 self.assertEqual(self.student['studycourse'].certificate.code, 'CERT2') 275 self.assertEqual(self.student['studycourse_1'].current_session, 2012) 276 self.assertEqual(self.student['studycourse'].current_session, 2013) 277 self.assertEqual(self.student['studycourse'].entry_session, 278 self.student['studycourse_1'].entry_session) 279 self.assertEqual(self.student['studycourse_1'].__name__, 'studycourse_1') 280 logfile = os.path.join( 281 self.app['datacenter'].storage, 'logs', 'students.log') 282 logcontent = open(logfile).read() 283 self.assertTrue('system - K1000000 - transferred from CERT1 to CERT2' 284 in logcontent) 285 messages = ' '.join(self.student.history.messages) 286 self.assertMatches( 287 '...<YYYY-MM-DD hh:mm:ss> UTC - ' 288 'Transferred from CERT1 to CERT2 by system', messages) 289 290 # The students_catalog has been updated. 291 cat = queryUtility(ICatalog, name='students_catalog') 292 results = cat.searchResults(certcode=('CERT1', 'CERT1')) 293 results = [x for x in results] 294 self.assertEqual(len(results), 0) 295 results = cat.searchResults(certcode=('CERT2', 'CERT2')) 296 results = [x for x in results] 297 self.assertEqual(len(results), 1) 298 assert results[0] is self.app['students'][self.student.student_id] 299 results = cat.searchResults(current_session=(2013,2013)) 300 results = [x for x in results] 301 self.assertEqual(len(results), 1) 302 assert results[0] is self.app['students'][self.student.student_id] 303 304 # Students can be transferred (only) two times. 305 error = self.student.transfer(self.certificate, 306 current_session=2013) 307 self.assertTrue(error == None) 308 error = self.student.transfer(self.certificate2, 309 current_session=2013) 310 self.assertTrue(error == -3) 311 self.assertEqual([i for i in self.student.keys()], 312 [u'accommodation', u'payments', u'studycourse', 313 u'studycourse_1', u'studycourse_2']) 314 315 # The students_catalog has been updated again. 316 cat = queryUtility(ICatalog, name='students_catalog') 317 results = cat.searchResults(certcode=('CERT1', 'CERT1')) 318 results = [x for x in results] 319 self.assertEqual(len(results), 1) 320 assert results[0] is self.app['students'][self.student.student_id] 321 return 238 322 239 323 class StudentFactoryTest(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.