Changeset 7273


Ignore:
Timestamp:
4 Dec 2011, 21:08:53 (13 years ago)
Author:
Henrik Bettermann
Message:

Add test for student data migration to be sure that student_ids provided in import files are correctly produced and that the random id generator is thus neutralized.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
2 edited

Legend:

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

    r7269 r7273  
    6161
    6262STUDYCOURSE_HEADER_FIELDS = STUDYCOURSE_SAMPLE_DATA.split(
     63    '\n')[0].split(',')
     64
     65STUDENT_SAMPLE_DATA_MIGRATION = open(
     66    os.path.join(os.path.dirname(__file__), 'sample_student_data_migration.csv'),
     67    'rb').read()
     68
     69STUDENT_HEADER_FIELDS_MIGRATION = STUDENT_SAMPLE_DATA_MIGRATION.split(
    6370    '\n')[0].split(',')
    6471
     
    98105        self.csv_file_update2 = os.path.join(
    99106            self.workdir, 'sample_student_data_update2.csv')
     107        self.csv_file_migration = os.path.join(
     108            self.workdir, 'sample_student_data_migration.csv')
    100109        open(self.csv_file, 'wb').write(STUDENT_SAMPLE_DATA)
    101110        open(self.csv_file_update, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE)
    102111        open(self.csv_file_update2, 'wb').write(STUDENT_SAMPLE_DATA_UPDATE2)
     112        open(self.csv_file_migration, 'wb').write(STUDENT_SAMPLE_DATA_MIGRATION)
    103113
    104114    def tearDown(self):
     
    180190            self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'remove')
    181191        self.assertEqual(num_warns,0)
     192        shutil.rmtree(os.path.dirname(fin_file))
     193
     194    def test_import_migration_data(self):
     195        num, num_warns, fin_file, fail_file = self.importer.doImport(
     196            self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION)
     197        self.assertEqual(num_warns,0)
     198        assert len(self.app['students'].keys()) == 4
     199        self.assertTrue('A123456' in self.app['students'].keys())
    182200        shutil.rmtree(os.path.dirname(fin_file))
    183201
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py

    r7196 r7273  
    300300                    continue
    301301                obj = self.callFactory()
    302                 self.updateEntry(obj, row, site)
     302                # Override all values in row, also
     303                # student_ids and applicant_ids which have been
     304                # generated in the respective __init__ methods before.
     305                self.updateEntry(obj, row, site)
    303306                try:
    304307                    self.addEntry(obj, row, site)
Note: See TracChangeset for help on using the changeset viewer.