Ignore:
Timestamp:
24 Feb 2022, 10:23:10 (3 years ago)
Author:
Henrik Bettermann
Message:

Improve export and reimport of previous study course data.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/tests
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r16828 r16831  
    4040    StudentStudyLevelProcessor, CourseTicketProcessor,
    4141    StudentOnlinePaymentProcessor, StudentVerdictProcessor,
    42     FirstStudentStudyCourseProcessor,
    43     FirstStudentStudyLevelProcessor,
    44     FirstCourseTicketProcessor)
     42    )
    4543from waeup.kofa.students.payments import StudentOnlinePayment
    4644from waeup.kofa.students.student import Student
     
    9593    '\n')[0].split(',')
    9694
     95FIRST_STUDYCOURSE_SAMPLE_DATA = open(
     96    os.path.join(os.path.dirname(__file__), 'sample_first_studycourse_data.csv'),
     97    'rb').read()
     98
     99FIRST_STUDYCOURSE_HEADER_FIELDS = FIRST_STUDYCOURSE_SAMPLE_DATA.split(
     100    '\n')[0].split(',')
     101
    97102TRANSFER_SAMPLE_DATA = open(
    98103    os.path.join(os.path.dirname(__file__), 'sample_transfer_data.csv'),
     
    140145    '\n')[0].split(',')
    141146
     147FIRST_STUDYLEVEL_SAMPLE_DATA = open(
     148    os.path.join(os.path.dirname(__file__), 'sample_first_studylevel_data.csv'),
     149    'rb').read()
     150
     151FIRST_STUDYLEVEL_HEADER_FIELDS = FIRST_STUDYLEVEL_SAMPLE_DATA.split(
     152    '\n')[0].split(',')
     153
    142154COURSETICKET_SAMPLE_DATA = open(
    143155    os.path.join(os.path.dirname(__file__), 'sample_courseticket_data.csv'),
     
    145157
    146158COURSETICKET_HEADER_FIELDS = COURSETICKET_SAMPLE_DATA.split(
     159    '\n')[0].split(',')
     160
     161FIRST_COURSETICKET_SAMPLE_DATA = open(
     162    os.path.join(os.path.dirname(__file__), 'sample_first_courseticket_data.csv'),
     163    'rb').read()
     164
     165FIRST_COURSETICKET_HEADER_FIELDS = FIRST_COURSETICKET_SAMPLE_DATA.split(
    147166    '\n')[0].split(',')
    148167
     
    11411160
    11421161    def test_import_firstcourse_with_content(self):
    1143         processor = FirstStudentStudyCourseProcessor()
     1162        processor = StudentStudyCourseProcessor()
    11441163        csv_file = os.path.join(
    1145             self.workdir, 'sample_studycourse_data.csv')
     1164            self.workdir, 'sample_first_studycourse_data.csv')
     1165        open(csv_file, 'wb').write(FIRST_STUDYCOURSE_SAMPLE_DATA)
    11461166        num, num_warns, fin_file, fail_file = processor.doImport(
    1147             csv_file, STUDYCOURSE_HEADER_FIELDS,'create')
     1167            csv_file, FIRST_STUDYCOURSE_HEADER_FIELDS,'create')
    11481168        self.assertEqual(num_warns,1)
    11491169        content = open(fail_file).read()
    11501170        self.assertTrue('current_level: not in range' in content)
    1151         studycourse = processor.getEntry(dict(reg_number='1'), self.app)
     1171        studycourse = processor.getEntry(
     1172            dict(reg_number='1', previous='1'), self.app)
    11521173        self.assertEqual(studycourse.certificate.code, u'CERT1')
    11531174        self.assertEqual(studycourse.__name__, u'studycourse_1')
     
    11561177        self.assertEqual([i for i in results[0].keys()],
    11571178            [u'accommodation', u'payments', u'studycourse', u'studycourse_1'])
    1158         processor = FirstStudentStudyLevelProcessor()
     1179
     1180        processor = StudentStudyLevelProcessor()
    11591181        csv_file = os.path.join(
    1160             self.workdir, 'sample_studylevel_data.csv')
     1182            self.workdir, 'sample_first_studylevel_data.csv')
     1183        open(csv_file, 'wb').write(FIRST_STUDYLEVEL_SAMPLE_DATA)
    11611184        num, num_warns, fin_file, fail_file = processor.doImport(
    1162             csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
     1185            csv_file, FIRST_STUDYLEVEL_HEADER_FIELDS,'create')
    11631186        self.assertEqual(num_warns,3)
    11641187        assert processor.entryExists(
     
    11721195        self.assertEqual([i for i in results[0]['studycourse_1'].keys()],
    11731196            [u'100', u'200'])
    1174         processor = FirstCourseTicketProcessor()
     1197
     1198        processor = CourseTicketProcessor()
    11751199        csv_file = os.path.join(
    1176             self.workdir, 'sample_courseticket_data.csv')
     1200            self.workdir, 'sample_first_courseticket_data.csv')
     1201        open(csv_file, 'wb').write(FIRST_COURSETICKET_SAMPLE_DATA)
    11771202        num, num_warns, fin_file, fail_file = processor.doImport(
    1178             csv_file, COURSETICKET_HEADER_FIELDS,'create')
     1203            csv_file, FIRST_COURSETICKET_HEADER_FIELDS,'create')
    11791204        assert processor.entryExists(
    1180             dict(reg_number='1', level='100', code='COURSE1'), self.app) is True
     1205            dict(reg_number='1', level='100',
     1206                 code='COURSE1', previous='1'), self.app) is True
    11811207        self.assertEqual([i for i in results[0]['studycourse_1']['100'].keys()],
    11821208            [u'COURSE1'])
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r16827 r16831  
    416416            result,
    417417            'certificate,current_level,current_session,current_verdict,'
    418             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    419 
    420             ',,,0,,,0,\r\n'
     418            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     419
     420            ',,,0,,,0,,0\r\n'
    421421            )
    422422        return
     
    433433            result,
    434434            'certificate,current_level,current_session,current_verdict,'
    435             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    436 
    437             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     435            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     436
     437            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    438438            )
    439439        return
     
    449449            result,
    450450            'certificate,current_level,current_session,current_verdict,'
    451             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    452 
    453             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     451            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     452
     453            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    454454            )
    455455        return
     
    464464            result,
    465465            'certificate,current_level,current_session,current_verdict,'
    466             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    467 
    468             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     466            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     467
     468            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    469469            )
    470470        return
     
    483483            result,
    484484            'certificate,current_level,current_session,current_verdict,'
    485             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    486 
    487             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     485            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     486
     487            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    488488            )
    489489        return
     
    501501            result,
    502502            'certificate,current_level,current_session,current_verdict,'
    503             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    504 
    505             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     503            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     504
     505            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    506506            )
    507507        return
     
    519519            result,
    520520            'certificate,current_level,current_session,current_verdict,'
    521             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    522 
    523             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n'
     521            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     522
     523            'CERT1,200,2012,0,ug_ft,2010,0,A111111,0\r\n'
    524524            )
    525525        return
     
    549549            result,
    550550            'certificate,current_level,current_session,current_verdict,'
    551             'entry_mode,entry_session,previous_verdict,student_id\r\n'
     551            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
    552552            )
    553553        error = self.student.transfer(self.certificate2, current_session=2013)
     
    558558            result,
    559559            'certificate,current_level,current_session,current_verdict,'
    560             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    561             'CERT1,200,2012,0,ug_ft,2010,0,A111111\r\n')
     560            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     561            'CERT1,200,2012,0,ug_ft,2010,0,A111111,1\r\n')
    562562        error = self.student.transfer(self.certificate,
    563563                                      current_session=2014,
     
    570570            result,
    571571            'certificate,current_level,current_session,current_verdict,'
    572             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    573             'CERT2,,2013,,transfer,2010,,A111111\r\n')
     572            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     573            'CERT2,,2013,,transfer,2010,,A111111,2\r\n')
    574574        exporter = StudentStudyCourseExporter()
    575575        exporter.export_all(self.app, self.outfile)
     
    578578            result,
    579579            'certificate,current_level,current_session,current_verdict,'
    580             'entry_mode,entry_session,previous_verdict,student_id\r\n'
    581             'CERT1,300,2014,,transfer,2010,,A111111\r\n')
     580            'entry_mode,entry_session,previous_verdict,student_id,previous\r\n'
     581            'CERT1,300,2014,,transfer,2010,,A111111,0\r\n')
    582582        return
    583583
     
    591591            'gpa,level,level_session,level_verdict,total_credits,'
    592592            'transcript_remark,validated_by,validation_date,student_id,'
    593             'number_of_tickets,certcode\r\n'
     593            'number_of_tickets,certcode,previous\r\n'
    594594            )
    595595        error = self.student.transfer(self.certificate2, current_session=2013)
     
    601601            'gpa,level,level_session,level_verdict,total_credits,'
    602602            'transcript_remark,validated_by,validation_date,student_id,'
    603             'number_of_tickets,certcode\r\n'
    604             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n' )
     603            'number_of_tickets,certcode,previous\r\n'
     604            '0.00,100,2012,A,100,,,,A111111,1,CERT1,1\r\n' )
    605605        study_level = StudentStudyLevel()
    606606        study_level.level_session = 2015
     
    620620            'gpa,level,level_session,level_verdict,total_credits,'
    621621            'transcript_remark,validated_by,validation_date,student_id,'
    622             'number_of_tickets,certcode\r\n'
    623             '0.00,400,2015,C,0,,,,A111111,0,CERT2\r\n')
     622            'number_of_tickets,certcode,previous\r\n'
     623            '0.00,400,2015,C,0,,,,A111111,0,CERT2,2\r\n')
    624624        exporter = StudentStudyLevelExporter()
    625625        exporter.export_all(self.app, self.outfile)
     
    629629            'gpa,level,level_session,level_verdict,total_credits,'
    630630            'transcript_remark,validated_by,validation_date,student_id,'
    631             'number_of_tickets,certcode\r\n')
     631            'number_of_tickets,certcode,previous\r\n')
    632632        return
    633633
     
    642642            'fcode,level,level_session,mandatory,outstanding,passmark,'
    643643            'score,semester,ticket_session,title,student_id,certcode,'
    644             'display_fullname\r\n'
     644            'display_fullname,previous\r\n'
    645645            )
    646646        error = self.student.transfer(self.certificate2, current_session=2013)
     
    653653            'fcode,level,level_session,mandatory,outstanding,passmark,'
    654654            'score,semester,ticket_session,title,student_id,certcode,'
    655             'display_fullname\r\n'
     655            'display_fullname,previous\r\n'
    656656            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,'
    657             'A111111,CERT1,Anna M. Tester\r\n')
     657            'A111111,CERT1,Anna M. Tester,1\r\n')
    658658        study_level = StudentStudyLevel()
    659659        study_level.level_session = 2015
     
    685685            'fcode,level,level_session,mandatory,outstanding,passmark,'
    686686            'score,semester,ticket_session,title,student_id,certcode,'
    687             'display_fullname\r\n1,1,CRS9,,150,DEP9,FAC9,400,2015,0,0,'
    688             '100,,2,,Course 9,A111111,CERT2,Anna M. Tester\r\n')
     687            'display_fullname,previous\r\n1,1,CRS9,,150,DEP9,FAC9,400,2015,0,0,'
     688            '100,,2,,Course 9,A111111,CERT2,Anna M. Tester,2\r\n')
    689689        exporter = CourseTicketExporter()
    690690        exporter.export_all(self.app, self.outfile)
     
    695695            'fcode,level,level_session,mandatory,outstanding,passmark,'
    696696            'score,semester,ticket_session,title,student_id,certcode,'
    697             'display_fullname\r\n'
     697            'display_fullname,previous\r\n'
    698698            )
    699699        return
     
    731731            'gpa,level,level_session,level_verdict,total_credits,'
    732732            'transcript_remark,validated_by,validation_date,'
    733             'student_id,number_of_tickets,certcode\r\n'
    734             '0.00,,,0,0,,,,,0,\r\n'
     733            'student_id,number_of_tickets,certcode,previous\r\n'
     734            '0.00,,,0,0,,,,,0,,0\r\n'
    735735            )
    736736        return
     
    749749            'gpa,level,level_session,level_verdict,total_credits,'
    750750            'transcript_remark,validated_by,validation_date,'
    751             'student_id,number_of_tickets,certcode\r\n'
    752             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n'
     751            'student_id,number_of_tickets,certcode,previous\r\n'
     752            '0.00,100,2012,A,100,,,,A111111,1,CERT1,0\r\n'
    753753            )
    754754        return
     
    765765            'gpa,level,level_session,level_verdict,total_credits,'
    766766            'transcript_remark,validated_by,validation_date,'
    767             'student_id,number_of_tickets,certcode\r\n'
    768             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n'
     767            'student_id,number_of_tickets,certcode,previous\r\n'
     768            '0.00,100,2012,A,100,,,,A111111,1,CERT1,0\r\n'
    769769            )
    770770        return
     
    780780            'gpa,level,level_session,level_verdict,total_credits,'
    781781            'transcript_remark,validated_by,validation_date,'
    782             'student_id,number_of_tickets,certcode\r\n'
    783             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n'
     782            'student_id,number_of_tickets,certcode,previous\r\n'
     783            '0.00,100,2012,A,100,,,,A111111,1,CERT1,0\r\n'
    784784            )
    785785        return
     
    799799            'gpa,level,level_session,level_verdict,total_credits,'
    800800            'transcript_remark,validated_by,validation_date,'
    801             'student_id,number_of_tickets,certcode\r\n'
    802             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n'
     801            'student_id,number_of_tickets,certcode,previous\r\n'
     802            '0.00,100,2012,A,100,,,,A111111,1,CERT1,0\r\n'
    803803            )
    804804        return
     
    818818            'gpa,level,level_session,level_verdict,total_credits,'
    819819            'transcript_remark,validated_by,validation_date,'
    820             'student_id,number_of_tickets,certcode\r\n'
    821             '0.00,100,2012,A,100,,,,A111111,1,CERT1\r\n'
     820            'student_id,number_of_tickets,certcode,previous\r\n'
     821            '0.00,100,2012,A,100,,,,A111111,1,CERT1,0\r\n'
    822822            )
    823823        return
     
    855855            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    856856            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    857             'display_fullname\r\n'
    858             '0,0,,,,,,,,0,0,,,,,,,,\r\n'
     857            'display_fullname,previous\r\n'
     858            '0,0,,,,,,,,0,0,,,,,,,,,0\r\n'
    859859            )
    860860        return
     
    874874            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    875875            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    876             'display_fullname\r\n'
     876            'display_fullname,previous\r\n'
    877877            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    878             'Anna M. Tester\r\n'
     878            'Anna M. Tester,0\r\n'
    879879            )
    880880        return
     
    891891            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    892892            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    893             'display_fullname\r\n'
     893            'display_fullname,previous\r\n'
    894894            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    895             'Anna M. Tester\r\n'
     895            'Anna M. Tester,0\r\n'
    896896            )
    897897        return
     
    907907            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    908908            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    909             'display_fullname\r\n'
     909            'display_fullname,previous\r\n'
    910910            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    911             'Anna M. Tester\r\n'
     911            'Anna M. Tester,0\r\n'
    912912            )
    913913        return
     
    926926            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    927927            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    928             'display_fullname\r\n'
     928            'display_fullname,previous\r\n'
    929929            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    930             'Anna M. Tester\r\n'
     930            'Anna M. Tester,0\r\n'
    931931            )
    932932        # We can set the course tickets level, semester and level_session
     
    940940            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    941941            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    942             'display_fullname\r\n'
     942            'display_fullname,previous\r\n'
    943943            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    944             'Anna M. Tester\r\n'
     944            'Anna M. Tester,0\r\n'
    945945            )
    946946        # 'all' does select all
     
    953953            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    954954            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    955             'display_fullname\r\n'
     955            'display_fullname,previous\r\n'
    956956            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    957             'Anna M. Tester\r\n'
     957            'Anna M. Tester,0\r\n'
    958958            )
    959959        # Level 200 tickets do not exist.
     
    965965            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    966966            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    967             'display_fullname\r\n'
     967            'display_fullname,previous\r\n'
    968968                        )
    969969        # Session 2013 tickets do not exist.
     
    976976            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    977977            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    978             'display_fullname\r\n'
     978            'display_fullname,previous\r\n'
    979979            )
    980980        # 1st semester tickets do not exist.
     
    987987            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    988988            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    989             'display_fullname\r\n'
     989            'display_fullname,previous\r\n'
    990990            )
    991991        # If the coursetickets catalog is used to filter students
     
    999999            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    10001000            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    1001             'display_fullname\r\n'
     1001            'display_fullname,previous\r\n'
    10021002            '1,1,CRS1,,100,DEP1,FAC1,100,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    1003             'Anna M. Tester\r\n'
     1003            'Anna M. Tester,0\r\n'
    10041004            )
    10051005        exporter.export_filtered(
     
    10101010            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    10111011            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    1012             'display_fullname\r\n'
     1012            'display_fullname,previous\r\n'
    10131013            )
    10141014        # Also tickets in probating levels are exported. Therefore
     
    10231023            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
    10241024            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
    1025             'display_fullname\r\n'
     1025            'display_fullname,previous\r\n'
    10261026            '1,1,CRS1,,100,DEP1,FAC1,110,2012,0,0,100,,2,,Course 1,A111111,CERT1,'
    1027             'Anna M. Tester\r\n'
     1027            'Anna M. Tester,0\r\n'
    10281028            )
    10291029        return
Note: See TracChangeset for help on using the changeset viewer.