Ignore:
Timestamp:
21 Sep 2012, 08:19:35 (12 years ago)
Author:
uli
Message:

Rollback r9209. Looks like multiple merges from trunk confuse svn when merging back into trunk.

Location:
main/waeup.kofa/branches/uli-zc-async
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-zc-async

  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/sample_payment_data.csv

    r9209 r9211  
    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
     1matric_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
     3100001,unpaid,schoolfee,3816951290712593757,,2010,0,BTECHBDT,19500,0942,Z0,2010-11-25 20:16:33.757 GMT+1,online
     4,paid,schoolfee,p1266236341955,3,2009,19500,BTECHBDT,19500,0615,00,2010/02/15 13:19:01,online
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_authentication.py

    r9209 r9211  
    6565    email = None
    6666    phone = None
    67     suspended = False
    6867
    6968
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_batching.py

    r9209 r9211  
    2323import unittest
    2424import datetime
    25 import grok
    2625from time import time
    27 from zope.event import notify
    2826from zope.component import createObject
    2927from zope.component.hooks import setSite, clearSite
    3028from zope.interface.verify import verifyClass, verifyObject
    31 from hurry.workflow.interfaces import IWorkflowState
    3229
    3330from waeup.kofa.app import University
     
    129126    '\n')[0].split(',')
    130127
    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 
    138128class StudentImportExportSetup(FunctionalTestCase):
    139129
     
    181171    def setup_student(self, student):
    182172        # set predictable values for `student`
    183         student.matric_number = u'234'
     173        student.matric_number = u'M123456'
    184174        student.adm_code = u'my adm code'
    185175        student.clearance_locked = False
    186176        student.clr_code = u'my clr code'
    187177        student.perm_address = u'Studentroad 21\nLagos 123456\n'
    188         student.reg_number = u'123'
     178        student.reg_number = u'123456'
     179        student.student_id = u'A111111'
    189180        student.firstname = u'Anna'
    190181        student.lastname = u'Tester'
     
    220211        ticket.passmark = 100
    221212        ticket.semester = 2
    222         study_level[ticket.code] = ticket
     213        study_level.addCourseTicket(ticket)
    223214        self.add_payment(student)
    224215        return student
     
    241232
    242233
    243 class StudentProcessorTest(StudentImportExportSetup):
     234
     235class StudentProcessorTest(FunctionalTestCase):
    244236
    245237    layer = FunctionalLayer
     
    247239    def setUp(self):
    248240        super(StudentProcessorTest, self).setUp()
     241        # Setup a sample site for each test
     242        app = University()
     243        self.dc_root = tempfile.mkdtemp()
     244        app['datacenter'].setStoragePath(self.dc_root)
     245
     246        # Prepopulate the ZODB...
     247        self.getRootFolder()['app'] = app
     248        # we add the site immediately after creation to the
     249        # ZODB. Catalogs and other local utilities are not setup
     250        # before that step.
     251        self.app = self.getRootFolder()['app']
     252        # Set site here. Some of the following setup code might need
     253        # to access grok.getSite() and should get our new app then
     254        setSite(app)
    249255
    250256        # Add student with subobjects
    251257        student = Student()
     258        student.firstname = u'Anna'
     259        student.lastname = u'Tester'
     260        student.reg_number = u'123'
     261        student.matric_number = u'234'
    252262        self.app['students'].addStudent(student)
    253         student = self.setup_student(student)
    254         notify(grok.ObjectModifiedEvent(student))
    255263        self.student = self.app['students'][student.student_id]
    256 
    257264        self.processor = StudentProcessor()
    258265        self.workdir = tempfile.mkdtemp()
     
    278285        open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES)
    279286
     287    def tearDown(self):
     288        super(StudentProcessorTest, self).tearDown()
     289        shutil.rmtree(self.workdir)
     290        shutil.rmtree(self.dc_root)
     291        clearSite()
     292        return
     293
    280294    def test_interface(self):
    281295        # Make sure we fulfill the interface contracts.
     
    329343        self.assertEqual(initial_stud_id, new_stud_id)
    330344        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 
    349345
    350346    def test_delEntry(self):
     
    490486        super(StudentStudyCourseProcessorTest, self).setUp()
    491487
    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 
    499488        # Import students with subobjects
    500489        student_file = os.path.join(self.workdir, 'sample_student_data.csv')
     
    543532            dict(reg_number='1', current_level='100'))
    544533        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.')
    559534
    560535    def test_import(self):
     
    692667        self.assertEqual(num_warns,2)
    693668        shutil.rmtree(os.path.dirname(fin_file))
     669       
    694670
    695671class CourseTicketProcessorTest(StudentImportExportSetup):
     
    705681        shutil.rmtree(os.path.dirname(fin_file))
    706682
    707         # Add course and certificate course
     683        # Add course and course referrer
    708684        self.course = createObject('waeup.Course')
    709685        self.course.code = 'COURSE1'
     
    713689        self.app['faculties']['fac1']['dep1'].courses.addCourse(
    714690            self.course)
    715         self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
     691        self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCourseRef(
    716692            self.course, level=100)
    717693
     
    779755        # Logging message from updateEntry,
    780756        self.assertTrue(
    781             'INFO - system - K1000000 - Course ticket in 100 updated: code=COURSE1, '
     757            'INFO - system - K1000000 - Course ticket updated: code=COURSE1, '
    782758            'mandatory=False, score=3'
    783759            in logcontent)
     
    793769        self.assertEqual(num_warns,2)
    794770        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)
    814771
    815772class PaymentProcessorTest(StudentImportExportSetup):
     
    827784        self.student = self.app['students'][student.student_id]
    828785        payment = createObject(u'waeup.StudentOnlinePayment')
    829         payment.p_id = 'p120'
     786        payment.p_id = 'p123'
    830787        self.student['payments'][payment.p_id] = payment
    831788
     
    841798            self.workdir, 'sample_payment_data.csv')
    842799        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)
    846800
    847801    def test_interface(self):
     
    855809            dict(student_id='ID_NONE', p_id='nonsense'), self.app) is None
    856810        assert self.processor.getEntry(
    857             dict(student_id=self.student.student_id, p_id='p120'),
    858             self.app) is self.student['payments']['p120']
     811            dict(student_id=self.student.student_id, p_id='p123'),
     812            self.app) is self.student['payments']['p123']
    859813        assert self.processor.getEntry(
    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)
     814            dict(student_id=self.student.student_id, p_id='XXXXXX123'),
     815            self.app) is self.student['payments']['p123']
    875816
    876817    def test_addEntry(self):
     
    890831            self.app)
    891832        self.assertEqual(len(self.student['payments'].keys()),3)
    892         self.assertEqual(self.student['payments']['p560'].p_id, 'p560')
     833        self.assertEqual(self.student['payments']['p456'].p_id, 'p456')
    893834
    894835    def test_checkConversion(self):
    895836        errs, inv_errs, conv_dict = self.processor.checkConversion(
    896             dict(p_id='3816951266236341955'))
     837            dict(reg_number='1', p_id='3816951266236341955'))
    897838        self.assertEqual(len(errs),0)
    898839        errs, inv_errs, conv_dict = self.processor.checkConversion(
    899             dict(p_id='p1266236341955'))
     840            dict(reg_number='1', p_id='p1266236341955'))
    900841        self.assertEqual(len(errs),0)
    901842        errs, inv_errs, conv_dict = self.processor.checkConversion(
    902             dict(p_id='nonsense'))
     843            dict(reg_number='1', p_id='nonsense'))
    903844        self.assertEqual(len(errs),1)
    904         timestamp = ("%d" % int(time()*10000))[1:]
     845        timestamp = "%d" % int(time()*1000)
    905846        p_id = "p%s" % timestamp
    906847        errs, inv_errs, conv_dict = self.processor.checkConversion(
    907             dict(p_id=p_id))
     848            dict(reg_number='1', p_id=p_id))
    908849        self.assertEqual(len(errs),0)
    909850
     
    913854        self.assertEqual(num_warns,0)
    914855        payment = self.processor.getEntry(dict(reg_number='1',
    915             p_id='p2907979737440'), self.app)
    916         self.assertEqual(payment.p_id, 'p2907979737440')
    917         self.assertTrue(payment.p_current)
     856            p_id='p1290797973744'), self.app)
     857        self.assertEqual(payment.p_id, 'p1290797973744')
    918858        cdate = payment.creation_date.strftime("%Y-%m-%d %H:%M:%S")
    919859        self.assertEqual(cdate, "2010-11-26 18:59:33")
    920860        self.assertEqual(str(payment.creation_date.tzinfo),'UTC')
    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))
     861        shutil.rmtree(os.path.dirname(fin_file))
     862
    932863        logcontent = open(self.logfile).read()
    933         # Logging message from updateEntry
     864        # Logging message from updateEntry,
    934865        self.assertTrue(
    935866            'INFO - system - K1000001 - Payment ticket updated: '
    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'
     867            'p_id=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'
    940871            in logcontent)
    941872
     
    950881        self.assertEqual(num_warns,0)
    951882        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 
    972883
    973884def test_suite():
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_browser.py

    r9209 r9211  
    118118        self.manage_clearance_path = self.student_path + '/manage_clearance'
    119119        self.edit_personal_path = self.student_path + '/edit_personal'
    120         self.manage_personal_path = self.student_path + '/manage_personal'
    121120        self.studycourse_path = self.student_path + '/studycourse'
    122121        self.payments_path = self.student_path + '/payments'
     
    171170        self.app['faculties']['fac1']['dep1'].courses.addCourse(
    172171            self.course)
    173         self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
     172        self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCourseRef(
    174173            self.course, level=100)
    175174
     
    404403    layer = FunctionalLayer
    405404
    406     def test_student_properties(self):
    407         self.student['studycourse'].current_level = 100
    408         self.assertEqual(self.student.current_level, 100)
    409         self.student['studycourse'].current_session = 2011
    410         self.assertEqual(self.student.current_session, 2011)
    411         self.student['studycourse'].current_verdict = 'A'
    412         self.assertEqual(self.student.current_verdict, 'A')
    413         return
    414 
    415405    def test_basic_auth(self):
    416406        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     
    464454        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    465455        self.assertEqual(self.browser.url, self.personal_path)
    466         self.browser.getLink("Manage").click()
    467         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    468         self.assertEqual(self.browser.url, self.manage_personal_path)
    469         self.browser.open(self.personal_path)
    470456        self.browser.getLink("Edit").click()
    471457        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     
    488474        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    489475        self.assertEqual(self.browser.url, self.history_path)
    490         self.assertMatches('...Admitted by Manager...',
     476        self.assertMatches('...Student admitted by Manager...',
    491477                           self.browser.contents)
    492478        # Only the Application Slip does not exist
     
    768754        self.assertEqual(student['studycourse'].current_session, 2005) # +1
    769755        self.assertEqual(student['studycourse'].current_level, 200) # +100
    770         self.assertEqual(student['studycourse'].current_verdict, '0') # 0 = Zero = not set
     756        self.assertEqual(student['studycourse'].current_verdict, 'NY') # NY = not set
    771757        self.assertEqual(student['studycourse'].previous_verdict, 'A')
    772758        self.browser.getControl(name="transition").value = ['register_courses']
     
    776762        self.browser.getControl(name="transition").value = ['return']
    777763        self.browser.getControl("Save").click()
    778         return
    779 
    780     def test_manage_pg_workflow(self):
    781         # Managers can pass through the whole workflow
    782         IWorkflowState(self.student).setState('school fee paid')
    783         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    784         student = self.app['students'][self.student_id]
    785         self.browser.open(self.manage_student_path)
    786         self.assertTrue('<option value="reset6">' in self.browser.contents)
    787         self.assertTrue('<option value="register_courses">' in self.browser.contents)
    788         self.assertTrue('<option value="reset5">' in self.browser.contents)
    789         self.certificate.study_mode = 'pg_ft'
    790         self.browser.open(self.manage_student_path)
    791         self.assertFalse('<option value="reset6">' in self.browser.contents)
    792         self.assertFalse('<option value="register_courses">' in self.browser.contents)
    793         self.assertTrue('<option value="reset5">' in self.browser.contents)
    794764        return
    795765
     
    806776        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    807777        self.browser.open(datacenter_path)
    808         self.browser.getLink('Upload data').click()
     778        self.browser.getLink('Upload CSV file').click()
    809779        filecontents = StringIO(open('students.csv', 'rb').read())
    810780        filewidget = self.browser.getControl(name='uploadfile:file')
    811781        filewidget.add_file(filecontents, 'text/plain', 'students.csv')
    812782        self.browser.getControl(name='SUBMIT').click()
    813         self.browser.getLink('Process data').click()
     783        self.browser.getLink('Batch processing').click()
    814784        button = lookup_submit_value(
    815785            'select', 'students_zope.mgr.csv', self.browser)
     
    832802""")
    833803        self.browser.open(datacenter_path)
    834         self.browser.getLink('Upload data').click()
     804        self.browser.getLink('Upload CSV file').click()
    835805        filecontents = StringIO(open('studycourses.csv', 'rb').read())
    836806        filewidget = self.browser.getControl(name='uploadfile:file')
    837807        filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv')
    838808        self.browser.getControl(name='SUBMIT').click()
    839         self.browser.getLink('Process data').click()
     809        self.browser.getLink('Batch processing').click()
    840810        button = lookup_submit_value(
    841811            'select', 'studycourses_zope.mgr.csv', self.browser)
     
    947917        self.assertTrue('clearance started' in self.browser.contents)
    948918        self.browser.open(self.history_path)
    949         self.assertTrue("Reset to 'clearance started' by My Public Name" in
     919        self.assertTrue("Reset to 'clearance' by My Public Name" in
    950920            self.browser.contents)
    951921        IWorkflowInfo(self.student).fireTransition('request_clearance')
     
    976946        self.app['users'].addUser('mrsadvise', 'mrsadvisesecret')
    977947        self.app['users']['mrsadvise'].email = 'mradvise@foo.ng'
    978         self.app['users']['mrsadvise'].title = u'Helen Procter'
     948        self.app['users']['mrsadvise'].title = 'Helen Procter'
    979949        # Assign local CourseAdviser100 role for a certificate
    980950        cert = self.app['faculties']['fac1']['dep1'].certificates['CERT1']
     
    1027997        # the 100L CA does see the 'Validate' button
    1028998        self.browser.open(L110_student_path)
    1029         self.assertFalse('Validate courses' in self.browser.contents)
     999        self.assertFalse('Validate' in self.browser.contents)
    10301000        IWorkflowInfo(self.student).fireTransition('register_courses')
    10311001        self.browser.open(L110_student_path)
    1032         self.assertFalse('Validate courses' in self.browser.contents)
     1002        self.assertFalse('Validate' in self.browser.contents)
    10331003        self.student['studycourse'].current_level = 110
    10341004        self.browser.open(L110_student_path)
    1035         self.assertTrue('Validate courses' in self.browser.contents)
     1005        self.assertTrue('Validate' in self.browser.contents)
    10361006        # ... but a 100L CA does not see the button on other levels
    10371007        studylevel2 = StudentStudyLevel()
     
    10411011        L200_student_path = self.studycourse_path + '/200'
    10421012        self.browser.open(L200_student_path)
    1043         self.assertFalse('Validate courses' in self.browser.contents)
     1013        self.assertFalse('Validate' in self.browser.contents)
    10441014        self.browser.open(L110_student_path)
    10451015        self.browser.getLink("Validate courses").click()
    10461016        self.assertTrue('Course list has been validated' in self.browser.contents)
    10471017        self.assertTrue('courses validated' in self.browser.contents)
    1048         self.assertEqual(self.student['studycourse']['110'].validated_by,
    1049             'Helen Procter')
    1050         self.assertMatches(
    1051             '<YYYY-MM-DD hh:mm:ss>',
    1052             self.student['studycourse']['110'].validation_date.strftime(
    1053                 "%Y-%m-%d %H:%M:%S"))
    10541018        self.browser.getLink("Reject courses").click()
    10551019        self.assertTrue('Course list request has been annulled.'
     
    10591023            '/contactstudent?subject=%s' % urlmessage)
    10601024        self.assertTrue('school fee paid' in self.browser.contents)
    1061         self.assertTrue(self.student['studycourse']['110'].validated_by is None)
    1062         self.assertTrue(self.student['studycourse']['110'].validation_date is None)
    10631025        IWorkflowInfo(self.student).fireTransition('register_courses')
    10641026        self.browser.open(L110_student_path)
     
    11801142        # and can perform actions
    11811143        IWorkflowInfo(self.student).fireTransition('admit')
    1182         # Students can't login if their account is suspended/deactivated
    1183         self.student.suspended = True
    11841144        self.browser.open(self.login_path)
    11851145        self.browser.getControl(name="form.login").value = self.student_id
    11861146        self.browser.getControl(name="form.password").value = 'spwd'
    11871147        self.browser.getControl("Login").click()
    1188         self.assertTrue(
    1189             'Your account has been deactivated.' in self.browser.contents)
    1190         self.student.suspended = False
    1191         self.browser.getControl("Login").click()
    1192         self.assertTrue(
    1193             'You logged in.' in self.browser.contents)
    1194         # Admitted student can upload a passport picture
     1148        # Student can upload a passport picture
    11951149        self.browser.open(self.student_path + '/change_portrait')
    11961150        ctrl = self.browser.getControl(name='passportuploadedit')
     
    12031157            '<img align="middle" height="125px" src="passport.jpg" />'
    12041158            in self.browser.contents)
    1205         # Students can open admission letter
    1206         self.browser.getLink("Base Data").click()
    1207         self.browser.getLink("Download admission letter").click()
    1208         self.assertEqual(self.browser.headers['Status'], '200 Ok')
    1209         self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
    12101159        # Student can view the clearance data
    1211         self.browser.open(self.student_path)
    12121160        self.browser.getLink("Clearance Data").click()
    12131161        # Student can't open clearance edit form before starting clearance
     
    12221170        self.assertMatches('...Not all required fields filled...',
    12231171                           self.browser.contents)
    1224         self.browser.open(self.student_path + '/edit_base')
    1225         self.browser.getControl(name="form.email").value = 'aa@aa.ng'
    1226         self.browser.getControl("Save").click()
     1172        self.student.email = 'aa@aa.ng'
    12271173        self.browser.open(self.student_path + '/start_clearance')
    12281174        self.browser.getControl(name="ac_series").value = '3'
     
    12391185        # Set the correct owner
    12401186        self.existing_clrac.owner = self.student_id
    1241         # clr_code might be set (and thus returns None) due importing
    1242         # an empty clr_code column.
    1243         self.student.clr_code = None
    12441187        self.browser.getControl("Start clearance now").click()
    12451188        self.assertMatches('...Clearance process has been started...',
     
    12921235        self.browser.getControl("Create course list now").click()
    12931236        self.browser.getLink("100").click()
    1294         self.browser.getLink("Edit course list").click()
     1237        self.browser.getLink("Add and remove courses").click()
    12951238        self.browser.getControl("Add course ticket").click()
    12961239        self.browser.getControl(name="form.course").value = ['COURSE1']
     
    13051248        self.browser.getControl("Create course list now").click()
    13061249        self.browser.getLink("200").click()
    1307         self.browser.getLink("Edit course list").click()
     1250        self.browser.getLink("Add and remove courses").click()
    13081251        self.browser.getControl("Add course ticket").click()
    13091252        self.browser.getControl(name="form.course").value = ['COURSE1']
     
    13431286        self.assertEqual(self.student.state, 'courses registered')
    13441287        return
    1345 
    1346     def test_student_clearance_wo_clrcode(self):
    1347         IWorkflowState(self.student).setState('clearance started')
    1348         self.browser.open(self.login_path)
    1349         self.browser.getControl(name="form.login").value = self.student_id
    1350         self.browser.getControl(name="form.password").value = 'spwd'
    1351         self.browser.getControl("Login").click()
    1352         self.student.clearance_locked = False
    1353         self.browser.open(self.edit_clearance_path)
    1354         self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'
    1355         self.browser.getControl("Save and request clearance").click()
    1356         self.assertMatches('...Clearance has been requested...',
    1357                            self.browser.contents)
    13581288
    13591289    def test_manage_payments(self):
     
    15861516        # The new SFE-0 pin can be used for starting new session
    15871517        self.browser.open(self.studycourse_path)
    1588         self.browser.getLink('Start new session').click()
     1518        self.browser.getLink('Start session').click()
    15891519        pin = self.app['accesscodes']['SFE-0'].keys()[0]
    15901520        parts = pin.split('-')[1:]
     
    15981528        return
    15991529
    1600     def test_student_previous_payments(self):
    1601         configuration = createObject('waeup.SessionConfiguration')
    1602         configuration.academic_session = 2000
    1603         configuration.clearance_fee = 3456.0
    1604         configuration.booking_fee = 123.4
    1605         self.student['studycourse'].entry_session = 2002
    1606         self.app['configuration'].addSessionConfiguration(configuration)
    1607         configuration2 = createObject('waeup.SessionConfiguration')
    1608         configuration2.academic_session = 2003
    1609         configuration2.clearance_fee = 3456.0
    1610         configuration2.booking_fee = 123.4
    1611         self.student['studycourse'].entry_session = 2002
    1612         self.app['configuration'].addSessionConfiguration(configuration2)
    1613         # Login
    1614         self.browser.open(self.login_path)
    1615         self.browser.getControl(name="form.login").value = self.student_id
    1616         self.browser.getControl(name="form.password").value = 'spwd'
    1617         self.browser.getControl("Login").click()
    1618 
    1619         # Students can add previous school fee payment tickets in any state.
    1620         IWorkflowState(self.student).setState('courses registered')
    1621         self.browser.open(self.payments_path)
    1622         self.browser.getControl("Add online payment ticket").click()
    1623         self.browser.getControl(name="form.p_category").value = ['schoolfee']
    1624         self.browser.getControl("Create ticket").click()
    1625 
    1626         # Amount cannot be determined since the state is not
    1627         # 'cleared' or 'returning'
    1628         self.assertMatches('...Amount could not be determined...',
    1629                            self.browser.contents)
    1630         self.assertMatches('...Would you like to pay for a previous session?...',
    1631                            self.browser.contents)
    1632 
    1633         # Previous session payment form is provided
    1634         self.browser.getControl(name="form.p_category").value = ['schoolfee']
    1635         self.browser.getControl(name="form.p_session").value = ['2000']
    1636         self.browser.getControl(name="form.p_level").value = ['300']
    1637         self.browser.getControl("Create ticket").click()
    1638         self.assertMatches('...The previous session must not fall below...',
    1639                            self.browser.contents)
    1640         self.browser.getControl(name="form.p_category").value = ['schoolfee']
    1641         self.browser.getControl(name="form.p_session").value = ['2004']
    1642         self.browser.getControl(name="form.p_level").value = ['300']
    1643         self.browser.getControl("Create ticket").click()
    1644         self.assertMatches('...This is not a previous session...',
    1645                            self.browser.contents)
    1646         self.browser.getControl(name="form.p_category").value = ['schoolfee']
    1647         self.browser.getControl(name="form.p_session").value = ['2003']
    1648         self.browser.getControl(name="form.p_level").value = ['300']
    1649         self.browser.getControl("Create ticket").click()
    1650         self.assertMatches('...ticket created...',
    1651                            self.browser.contents)
    1652         ctrl = self.browser.getControl(name='val_id')
    1653         value = ctrl.options[0]
    1654         self.browser.getLink(value).click()
    1655         self.assertMatches('...Amount Authorized...',
    1656                            self.browser.contents)
    1657         self.assertEqual(self.student['payments'][value].amount_auth, 20000.0)
    1658 
    1659         # Payment session is properly set
    1660         self.assertEqual(self.student['payments'][value].p_session, 2003)
    1661         self.assertEqual(self.student['payments'][value].p_level, 300)
    1662 
    1663         # We simulate the approval
    1664         self.browser.open(self.browser.url + '/fake_approve')
    1665         self.assertMatches('...Payment approved...',
    1666                           self.browser.contents)
    1667 
    1668         # No AC has been created
    1669         self.assertEqual(len(self.app['accesscodes']['SFE-0'].keys()), 0)
    1670         self.assertTrue(self.student['payments'][value].ac is None)
    1671 
    1672         # Current payment flag is set False
    1673         self.assertFalse(self.student['payments'][value].p_current)
    1674         return
    1675 
    1676     def test_student_postgraduate_payments(self):
     1530    def test_postgraduate_payments(self):
    16771531        self.certificate.study_mode = 'pg_ft'
    16781532        self.certificate.start_level = 999
     
    16981552                           self.browser.contents)
    16991553        # Payment session and level are current ones.
    1700         # Postgrads have to pay school_fee_1.
     1554        # Postgrads have to school_fee_1.
    17011555        self.assertEqual(self.student['payments'][value].amount_auth, 40000.0)
    17021556        self.assertEqual(self.student['payments'][value].p_session, 2004)
     
    17111565        # The new SFE-0 pin can be used for starting session
    17121566        self.browser.open(self.studycourse_path)
    1713         self.browser.getLink('Start new session').click()
     1567        self.browser.getLink('Start session').click()
    17141568        pin = self.app['accesscodes']['SFE-0'].keys()[0]
    17151569        parts = pin.split('-')[1:]
     
    17511605        # The new SFE-1 pin can be used for starting new session
    17521606        self.browser.open(self.studycourse_path)
    1753         self.browser.getLink('Start new session').click()
     1607        self.browser.getLink('Start session').click()
    17541608        self.browser.getControl(name="ac_series").value = sfeseries
    17551609        self.browser.getControl(name="ac_number").value = sfenumber
     
    19931847        self.browser.getControl(name="form.identifier").value = '123'
    19941848        self.browser.getControl(name="form.email").value = 'aa@aa.ng'
    1995         self.browser.getControl("Send login credentials").click()
     1849        self.browser.getControl("Get login credentials").click()
    19961850        self.assertTrue('An email with' in self.browser.contents)
     1851
     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)
    19971868
    19981869    def test_change_current_mode(self):
     
    20171888        self.assertTrue('Employer' in self.browser.contents)
    20181889
    2019     def test_activate_deactivate_buttons(self):
    2020         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    2021         self.browser.open(self.student_path)
    2022         self.browser.getLink("Deactivate").click()
    2023         self.assertTrue(
    2024             'Student account has been deactivated.' in self.browser.contents)
    2025         self.assertTrue(
    2026             'Base Data (account deactivated)' in self.browser.contents)
    2027         self.assertTrue(self.student.suspended)
    2028         self.browser.getLink("Activate").click()
    2029         self.assertTrue(
    2030             'Student account has been activated.' in self.browser.contents)
    2031         self.assertFalse(
    2032             'Base Data (account deactivated)' in self.browser.contents)
    2033         self.assertFalse(self.student.suspended)
    2034         # History messages have been added ...
    2035         self.browser.getLink("History").click()
    2036         self.assertTrue(
    2037             'Student account deactivated by Manager<br />' in self.browser.contents)
    2038         self.assertTrue(
    2039             'Student account activated by Manager<br />' in self.browser.contents)
    2040         # ... and actions have been logged.
    2041         logfile = os.path.join(
    2042             self.app['datacenter'].storage, 'logs', 'students.log')
    2043         logcontent = open(logfile).read()
    2044         self.assertTrue('zope.mgr - students.browser.StudentDeactivatePage - '
    2045                         'K1000000 - account deactivated' in logcontent)
    2046         self.assertTrue('zope.mgr - students.browser.StudentActivatePage - '
    2047                         'K1000000 - account activated' in logcontent)
    2048 
    2049     def test_student_transfer(self):
    2050         # Add second certificate
    2051         self.certificate2 = createObject('waeup.Certificate')
    2052         self.certificate2.code = u'CERT2'
    2053         self.certificate2.study_mode = 'ug_ft'
    2054         self.certificate2.start_level = 999
    2055         self.certificate2.end_level = 999
    2056         self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
    2057             self.certificate2)
    2058 
    2059         # Add study level to old study course
    2060         studylevel = createObject(u'waeup.StudentStudyLevel')
    2061         studylevel.level = 200
    2062         self.student['studycourse'].addStudentStudyLevel(
    2063             self.certificate, studylevel)
    2064 
    2065         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    2066         self.browser.open(self.student_path)
    2067         self.browser.getLink("Transfer").click()
    2068         self.browser.getControl(name="form.certificate").value = ['CERT2']
    2069         self.browser.getControl(name="form.current_session").value = ['2011']
    2070         self.browser.getControl(name="form.current_level").value = ['200']
    2071         self.browser.getControl("Transfer").click()
    2072         self.assertTrue(
    2073             'Current level does not match certificate levels'
    2074             in self.browser.contents)
    2075         self.browser.getControl(name="form.current_level").value = ['999']
    2076         self.browser.getControl("Transfer").click()
    2077         self.assertTrue('Successfully transferred' in self.browser.contents)
    2078 
    2079         # Add study level to new study course
    2080         studylevel = createObject(u'waeup.StudentStudyLevel')
    2081         studylevel.level = 200
    2082         self.student['studycourse'].addStudentStudyLevel(
    2083             self.certificate, studylevel)
    2084 
    2085         # Edit and add pages are locked for old study courses
    2086         self.browser.open(self.student_path + '/studycourse/manage')
    2087         self.assertFalse('The requested form is locked' in self.browser.contents)
    2088         self.browser.open(self.student_path + '/studycourse_1/manage')
    2089         self.assertTrue('The requested form is locked' in self.browser.contents)
    2090 
    2091         self.browser.open(self.student_path + '/studycourse/start_session')
    2092         self.assertFalse('The requested form is locked' in self.browser.contents)
    2093         self.browser.open(self.student_path + '/studycourse_1/start_session')
    2094         self.assertTrue('The requested form is locked' in self.browser.contents)
    2095 
    2096         IWorkflowState(self.student).setState('school fee paid')
    2097         self.browser.open(self.student_path + '/studycourse/add')
    2098         self.assertFalse('The requested form is locked' in self.browser.contents)
    2099         self.browser.open(self.student_path + '/studycourse_1/add')
    2100         self.assertTrue('The requested form is locked' in self.browser.contents)
    2101 
    2102         self.browser.open(self.student_path + '/studycourse/200/manage')
    2103         self.assertFalse('The requested form is locked' in self.browser.contents)
    2104         self.browser.open(self.student_path + '/studycourse_1/200/manage')
    2105         self.assertTrue('The requested form is locked' in self.browser.contents)
    2106 
    2107         self.browser.open(self.student_path + '/studycourse/200/validate_courses')
    2108         self.assertFalse('The requested form is locked' in self.browser.contents)
    2109         self.browser.open(self.student_path + '/studycourse_1/200/validate_courses')
    2110         self.assertTrue('The requested form is locked' in self.browser.contents)
    2111 
    2112         self.browser.open(self.student_path + '/studycourse/200/reject_courses')
    2113         self.assertFalse('The requested form is locked' in self.browser.contents)
    2114         self.browser.open(self.student_path + '/studycourse_1/200/reject_courses')
    2115         self.assertTrue('The requested form is locked' in self.browser.contents)
    2116 
    2117         self.browser.open(self.student_path + '/studycourse/200/add')
    2118         self.assertFalse('The requested form is locked' in self.browser.contents)
    2119         self.browser.open(self.student_path + '/studycourse_1/200/add')
    2120         self.assertTrue('The requested form is locked' in self.browser.contents)
    2121 
    2122         self.browser.open(self.student_path + '/studycourse/200/edit')
    2123         self.assertFalse('The requested form is locked' in self.browser.contents)
    2124         self.browser.open(self.student_path + '/studycourse_1/200/edit')
    2125         self.assertTrue('The requested form is locked' in self.browser.contents)
    2126 
    21271890class StudentRequestPWTests(StudentsFullSetup):
    21281891    # Tests for student registration
     
    21311894
    21321895    def test_request_pw(self):
    2133         # Student with wrong number can't be found.
     1896        # Student with wrong reg_number can't be found.
    21341897        self.browser.open('http://localhost/app/requestpw')
    21351898        self.browser.getControl(name="form.firstname").value = 'Anna'
    2136         self.browser.getControl(name="form.number").value = 'anynumber'
     1899        self.browser.getControl(name="form.reg_number").value = 'anynumber'
    21371900        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
    2138         self.browser.getControl("Send login credentials").click()
     1901        self.browser.getControl("Get login credentials").click()
    21391902        self.assertTrue('No student record found.'
    21401903            in self.browser.contents)
     
    21431906        self.browser.open('http://localhost/app/requestpw')
    21441907        self.browser.getControl(name="form.firstname").value = 'Johnny'
    2145         self.browser.getControl(name="form.number").value = '123'
     1908        self.browser.getControl(name="form.reg_number").value = '123'
    21461909        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
    2147         self.browser.getControl("Send login credentials").click()
     1910        self.browser.getControl("Get login credentials").click()
    21481911        self.assertTrue('No student record found.'
    21491912            in self.browser.contents)
     
    21511914        # password has been set and used.
    21521915        self.browser.getControl(name="form.firstname").value = 'Anna'
    2153         self.browser.getControl(name="form.number").value = '123'
    2154         self.browser.getControl("Send login credentials").click()
     1916        self.browser.getControl(name="form.reg_number").value = '123'
     1917        self.browser.getControl("Get login credentials").click()
    21551918        self.assertTrue('Your password has already been set and used.'
    21561919            in self.browser.contents)
     
    21591922        # The firstname field, used for verification, is not case-sensitive.
    21601923        self.browser.getControl(name="form.firstname").value = 'aNNa'
    2161         self.browser.getControl(name="form.number").value = '123'
     1924        self.browser.getControl(name="form.reg_number").value = '123'
    21621925        self.browser.getControl(name="form.email").value = 'new@yy.zz'
    2163         self.browser.getControl("Send login credentials").click()
     1926        self.browser.getControl("Get login credentials").click()
    21641927        # Yeah, we succeded ...
    2165         self.assertTrue('Your password request was successful.'
    2166             in self.browser.contents)
    2167         # We can also use the matric_number instead.
    2168         self.browser.open('http://localhost/app/requestpw')
    2169         self.browser.getControl(name="form.firstname").value = 'aNNa'
    2170         self.browser.getControl(name="form.number").value = '234'
    2171         self.browser.getControl(name="form.email").value = 'new@yy.zz'
    2172         self.browser.getControl("Send login credentials").click()
    21731928        self.assertTrue('Your password request was successful.'
    21741929            in self.browser.contents)
     
    21791934            email=('new@yy.zz', 'new@yy.zz')))
    21801935        self.assertEqual(self.student,results[0])
    2181         logfile = os.path.join(
    2182             self.app['datacenter'].storage, 'logs', 'main.log')
    2183         logcontent = open(logfile).read()
    2184         self.assertTrue('zope.anybody - students.browser.StudentRequestPasswordPage - '
    2185                         '234 (K1000000) - new@yy.zz' in logcontent)
    21861936        return
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_dynamicroles.py

    r9209 r9211  
    2525    Test as APRMTest, Manageable)
    2626from waeup.kofa.testing import FunctionalLayer
    27 from waeup.kofa.app import University
    2827from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    2928from waeup.kofa.students import Student, StudentPrincipalRoleManager
     
    4948    def setUp(self):
    5049        super(StudentPrincipalRoleManagerFunctionalTests, self).setUp()
     50        self.officer_role = 'waeup.StudentsClearanceOfficer'
    5151        # assign clearance permissions for a virtual officer
    5252        prm = IPrincipalRoleManager(self.app['faculties']['fac1']['dep1'])
    5353        prm.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'alice')
    54         prm.assignRoleToPrincipal('waeup.local.PGClearanceOfficer', 'bob')
    55         prm.assignRoleToPrincipal('waeup.local.UGClearanceOfficer', 'anne')
    5654        return
    5755
     
    7674        # student
    7775        prm = IPrincipalRoleManager(self.student)
    78         result = prm.getRolesForPrincipal('claus')
     76        result = prm.getRolesForPrincipal('bob')
    7977        self.assertEqual(result, [])
    8078        return
     
    8583        prm = IPrincipalRoleManager(self.student)
    8684        result = prm.getRolesForPrincipal('alice')
    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)])
     85        self.assertEqual(result, [(self.officer_role, Allow)])
    10286        return
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_export.py

    r9209 r9211  
    4444            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
    4545            'firstname,lastname,matric_number,middlename,nationality,'
    46             'perm_address,phone,reg_number,sex,student_id,suspended,password,'
     46            'perm_address,phone,reg_number,sex,student_id,password,'
    4747            'state,history,certcode\r\n'
    4848
    4949            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    50             'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
    51             '+234-123-12345#,123,f,A111111,0,,created'
     50            'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
     51            '+234-123-12345,123456,f,A111111,,created'
    5252            in result
    5353            )
     
    6464            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
    6565            'firstname,lastname,matric_number,middlename,nationality,'
    66             'perm_address,phone,reg_number,sex,student_id,suspended,password,'
     66            'perm_address,phone,reg_number,sex,student_id,password,'
    6767            'state,history,certcode\r\n'
    6868
    6969            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    70             'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
    71             '+234-123-12345#,123,f,A111111,0,,created'
     70            'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
     71            '+234-123-12345,123456,f,A111111,,created'
    7272            in result
    7373            )
     
    8383            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
    8484            'firstname,lastname,matric_number,middlename,nationality,'
    85             'perm_address,phone,reg_number,sex,student_id,suspended,password,'
     85            'perm_address,phone,reg_number,sex,student_id,password,'
    8686            'state,history,certcode\r\n'
    8787
    8888            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
    89             'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",'
    90             '+234-123-12345#,123,f,A111111,0,,created'
     89            'Anna,Tester,M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'
     90            '+234-123-12345,123456,f,A111111,,created'
    9191            in result
    9292            )
     
    127127            'entry_mode,entry_session,previous_verdict,student_id\r\n'
    128128
    129             ',,,0,,,0,\r\n'
     129            ',,,NY,,,NY,\r\n'
    130130            )
    131131        return
     
    144144            'entry_mode,entry_session,previous_verdict,student_id\r\n'
    145145
    146             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     146            'CERT1,200,2012,NY,ug_ft,2010,NY,A111111\r\n'
    147147            )
    148148        return
     
    160160            'entry_mode,entry_session,previous_verdict,student_id\r\n'
    161161
    162             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     162            'CERT1,200,2012,NY,ug_ft,2010,NY,A111111\r\n'
    163163            )
    164164        return
     
    175175            'entry_mode,entry_session,previous_verdict,student_id\r\n'
    176176
    177             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     177            'CERT1,200,2012,NY,ug_ft,2010,NY,A111111\r\n'
    178178            )
    179179        return
     
    209209        self.assertEqual(
    210210            result,
    211             'level,level_session,level_verdict,validated_by,validation_date,'
    212             'student_id\r\n'
    213             ',,0,,,\r\n'
     211            'level,level_session,level_verdict,student_id\r\n'
     212            ',,NY,\r\n'
    214213            )
    215214        return
     
    226225        self.assertEqual(
    227226            result,
    228             'level,level_session,level_verdict,validated_by,validation_date,'
    229             'student_id\r\n'
    230             '100,2012,A,,,A111111\r\n'
     227            'level,level_session,level_verdict,student_id\r\n'
     228            '100,2012,A,A111111\r\n'
    231229            )
    232230        return
     
    241239        self.assertEqual(
    242240            result,
    243             'level,level_session,level_verdict,validated_by,validation_date,'
    244             'student_id\r\n'
    245             '100,2012,A,,,A111111\r\n'
     241            'level,level_session,level_verdict,student_id\r\n'
     242            '100,2012,A,A111111\r\n'
    246243            )
    247244        return
     
    255252        self.assertEqual(
    256253            result,
    257             'level,level_session,level_verdict,validated_by,validation_date,'
    258             'student_id\r\n'
    259             '100,2012,A,,,A111111\r\n'
     254            'level,level_session,level_verdict,student_id\r\n'
     255            '100,2012,A,A111111\r\n'
    260256            )
    261257        return
     
    375371        self.assertEqual(
    376372            result,
    377             'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     373            'ac,amount_auth,creation_date,p_category,p_id,'
    378374            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
    379375            'r_code,r_desc,student_id\r\n'
    380376
    381             ',0.0,2012-04-01 13:12:01,schoolfee,1,,,,,unpaid,,0.0,,,\r\n'
     377            ',0.0,2012-04-01 13:12:01,schoolfee,,,,,unpaid,,0.0,,,\r\n'
    382378            )
    383379        return
     
    393389        self.assertEqual(
    394390            result,
    395             'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     391            'ac,amount_auth,creation_date,p_category,p_id,'
    396392            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
    397393            'r_code,r_desc,student_id\r\n'
    398394
    399             '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
     395            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
    400396            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
    401397            'r-code,,A111111\r\n'
     
    412408        self.assertEqual(
    413409            result,
    414             'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     410            'ac,amount_auth,creation_date,p_category,p_id,'
    415411            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
    416412            'r_code,r_desc,student_id\r\n'
    417413
    418             '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
     414            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
    419415            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
    420416            'r-code,,A111111\r\n'
     
    431427        self.assertEqual(
    432428            result,
    433             'ac,amount_auth,creation_date,p_category,p_current,p_id,'
     429            'ac,amount_auth,creation_date,p_category,p_id,'
    434430            'p_item,p_level,p_session,p_state,payment_date,r_amount_approved,'
    435431            'r_code,r_desc,student_id\r\n'
    436432
    437             '666,0.0,2012-04-01 13:12:01,schoolfee,1,my-id,'
     433            '666,0.0,2012-04-01 13:12:01,schoolfee,my-id,'
    438434            'p-item,100,2012,unpaid,2012-04-01 14:12:01,12.12,'
    439435            'r-code,,A111111\r\n'
  • main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/tests/test_student.py

    r9209 r9211  
    2121import re
    2222import unittest
    23 import grok
    2423from cStringIO import StringIO
    2524from datetime import tzinfo
    26 from zope.component import getUtility, queryUtility, createObject
    27 from zope.catalog.interfaces import ICatalog
     25from zope.component import getUtility
    2826from zope.component.interfaces import IFactory
    29 from zope.event import notify
    3027from zope.interface import verify
    31 from zope.schema.interfaces import RequiredMissing
    3228from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
    3329from waeup.kofa.students.export import EXPORTER_NAMES
     
    133129        studylevel = StudentStudyLevel()
    134130        self.assertRaises(
    135             TypeError, studylevel.addCourseTicket, department, department)
     131            TypeError, studylevel.addCourseTicket, department)
    136132
    137133    def test_booking_date(self):
     
    240236        return
    241237
    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
    322238
    323239class StudentFactoryTest(FunctionalTestCase):
Note: See TracChangeset for help on using the changeset viewer.