Ignore:
Timestamp:
26 Apr 2012, 14:30:24 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test for duplicate reg_numbers and matric_numbers.

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

Legend:

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

    r8287 r8289  
    8181    '\n')[0].split(',')
    8282
     83STUDENT_SAMPLE_DATA_DUPLICATES = open(
     84    os.path.join(os.path.dirname(__file__), 'sample_student_data_duplicates.csv'),
     85    'rb').read()
     86
     87STUDENT_HEADER_FIELDS_DUPLICATES = STUDENT_SAMPLE_DATA_DUPLICATES.split(
     88    '\n')[0].split(',')
     89
    8390STUDYLEVEL_SAMPLE_DATA = open(
    8491    os.path.join(os.path.dirname(__file__), 'sample_studylevel_data.csv'),
     
    174181        self.csv_file_migration = os.path.join(
    175182            self.workdir, 'sample_student_data_migration.csv')
     183        self.csv_file_duplicates = os.path.join(
     184            self.workdir, 'sample_student_data_duplicates.csv')
    176185        open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA)
    177186        open(self.csv_file_update, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE)
    178187        open(self.csv_file_update2, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE2)
    179188        open(self.csv_file_migration, 'wb').write(STUDENT_SAMPLE_DATA_MIGRATION)
     189        open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES)
    180190
    181191    def tearDown(self):
     
    321331        shutil.rmtree(os.path.dirname(fin_file))
    322332
     333    def test_import_duplicate_data(self):
     334        num, num_warns, fin_file, fail_file = self.processor.doImport(
     335            self.csv_file_duplicates, STUDENT_HEADER_FIELDS_DUPLICATES)
     336        content = open(fail_file).read()
     337        self.assertEqual(num_warns,3)
     338        self.assertEqual(
     339            content,
     340            'reg_number,firstname,student_id,sex,email,phone,state,date_of_birth,lastname,password,matric_number,--ERRORS--\r\n'
     341            '1,Aaren,B123456,m,aa@aa.ng,1234,cleared,1990-01-03,Finau,mypw1,100001,reg_number: reg_number\r\n'
     342            '2,Aaren,C123456,m,aa@aa.ng,1234,admitted,1990-01-04,Berson,mypw1,100000,matric_number: matric_number\r\n'
     343            '1,Frank,F123456,m,aa@aa.ng,1234,,1990-01-06,Meyer,,100000,reg_number: reg_number; matric_number: matric_number\r\n'
     344            )
     345        shutil.rmtree(os.path.dirname(fin_file))
    323346
    324347class StudentStudyCourseProcessorTest(StudentImportExportSetup):
Note: See TracChangeset for help on using the changeset viewer.