Ignore:
Timestamp:
25 Oct 2012, 21:52:10 (12 years ago)
Author:
Henrik Bettermann
Message:

Reorganize ICourseTicket. Add ICourseTicketImport which validates a new field called level_session.

Customize checkConversion of CourseTicketProcessor?:
If level_session is provided in row the importer checks if
the parent studylevel exists and if its level_session
attribute corresponds with the expected value in row. The error message
then tells us why course result import fails.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_courseticket_data.csv

    r7665 r9420  
    1 reg_number,matric_number,level,code,score,mandatory
    2 1,,100,COURSE1,1,True
    3 2,,100,COURSE1,2,False
    4 ,100002,100,COURSE1,3,False
    5 1,,nonsense,COURSE1,5,
    6 1,,100,NONSENSE,5,
     1reg_number,matric_number,level,code,score,mandatory,level_session
     21,,100,COURSE1,1,True,
     32,,100,COURSE1,2,False,
     4,100002,100,COURSE1,3,False,
     51,,nonsense,COURSE1,5,,
     61,,100,NONSENSE,5,,
     71,,200,COURSE1,6,,2004
     81,,300,COURSE1,6,,2008
     91,,300,COURSE1,6,,200888
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9302 r9420  
    733733
    734734    def test_import(self):
    735 
    736735        num, num_warns, fin_file, fail_file = self.processor.doImport(
    737736            self.csv_file, COURSETICKET_HEADER_FIELDS,'create')
    738 
    739         self.assertEqual(num_warns,2)
     737        fail_file = open(fail_file).read()
     738        self.assertEqual(num_warns,5)
     739        self.assertEqual(fail_file,
     740            'reg_number,code,mandatory,level,level_session,score,matric_number,--ERRORS--\r\n'
     741            '1,COURSE1,,nonsense,,5,,Not all parents do exist yet. Skipping\r\n'
     742            '1,NONSENSE,,100,,5,,code: non-existent\r\n'
     743            '1,COURSE1,,200,2004,6,,level_session: does not match 2008\r\n'
     744            '1,COURSE1,,300,2008,6,,level: does not exist\r\n'
     745            '1,COURSE1,,300,200888,6,,level_session: Invalid value; level: does not exist\r\n')
    740746        assert self.processor.entryExists(
    741747            dict(reg_number='1', level='100', code='COURSE1'),
     
    772778        num, num_warns, fin_file, fail_file = self.processor.doImport(
    773779            self.csv_file, COURSETICKET_HEADER_FIELDS,'update')
    774         self.assertEqual(num_warns,2)
     780        fail_file = open(fail_file).read()
     781        self.assertEqual(num_warns,5)
     782        self.assertEqual(fail_file,
     783            'reg_number,code,mandatory,level,level_session,score,matric_number,--ERRORS--\r\n'
     784            '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,5,<IGNORE>,Cannot update: no such entry\r\n'
     785            '1,NONSENSE,<IGNORE>,100,<IGNORE>,5,<IGNORE>,code: non-existent\r\n'
     786            '1,COURSE1,<IGNORE>,200,2004,6,<IGNORE>,level_session: does not match 2008\r\n'
     787            '1,COURSE1,<IGNORE>,300,2008,6,<IGNORE>,level: does not exist\r\n'
     788            '1,COURSE1,<IGNORE>,300,200888,6,<IGNORE>,level_session: Invalid value; level: does not exist\r\n')
    775789        shutil.rmtree(os.path.dirname(fin_file))
    776790
     
    786800        num, num_warns, fin_file, fail_file = self.processor.doImport(
    787801            self.csv_file, COURSETICKET_HEADER_FIELDS,'remove')
    788         self.assertEqual(num_warns,2)
     802        self.assertEqual(num_warns,5)
    789803        assert self.processor.entryExists(
    790804            dict(reg_number='1', level='100', code='COURSE1'), self.app) is False
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9412 r9420  
    161161        self.certificate.school_fee_1 = 40000.0
    162162        self.certificate.school_fee_2 = 20000.0
    163         self.app['faculties']['fac1'] = Faculty(code='fac1')
    164         self.app['faculties']['fac1']['dep1'] = Department(code='dep1')
     163        self.app['faculties']['fac1'] = Faculty(code=u'fac1')
     164        self.app['faculties']['fac1']['dep1'] = Department(code=u'dep1')
    165165        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
    166166            self.certificate)
Note: See TracChangeset for help on using the changeset viewer.