Ignore:
Timestamp:
14 Oct 2012, 04:54:11 (12 years ago)
Author:
Henrik Bettermann
Message:

Reorganize course batch processing. Use courses_catalog for getting entry in update mode.

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

Legend:

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

    r9293 r9333  
    7272
    7373COURSE_HEADER_FIELDS = COURSE_SAMPLE_DATA.split(
     74    '\n')[0].split(',')
     75
     76COURSE_SAMPLE_DATA_UPDATE = open(
     77    os.path.join(os.path.dirname(__file__), 'sample_course_data_update.csv'),
     78    'rb').read()
     79
     80COURSE_HEADER_FIELDS_UPDATE = COURSE_SAMPLE_DATA_UPDATE.split(
    7481    '\n')[0].split(',')
    7582
     
    441448        self.row4 = dict(department_code='DEP1', faculty_code='FAC1', code="CRS1")
    442449
    443         self.csv_file_course = os.path.join(self.workdir, 'sample_course_data.csv')
     450        self.csv_file_course = os.path.join(
     451            self.workdir, 'sample_course_data.csv')
    444452        open(self.csv_file_course, 'wb').write(COURSE_SAMPLE_DATA)
     453        self.csv_file_course_update = os.path.join(
     454            self.workdir, 'sample_course_data_update.csv')
     455        open(self.csv_file_course_update, 'wb').write(COURSE_SAMPLE_DATA_UPDATE)
    445456        return
    446457
     
    513524        self.assertEqual(user_name, 'anne')
    514525        self.assertEqual(local_role, 'waeup.local.Lecturer')
     526        shutil.rmtree(os.path.dirname(fin_file))
     527        return
     528
     529    def test_import_update(self):
     530        num, num_warns, fin_file, fail_file = self.proc.doImport(
     531            self.csv_file_course, COURSE_HEADER_FIELDS)
     532        shutil.rmtree(os.path.dirname(fin_file))
     533        num, num_warns, fin_file, fail_file = self.proc.doImport(
     534            self.csv_file_course_update, COURSE_HEADER_FIELDS_UPDATE, 'update')
     535        self.assertEqual(num_warns,0)
     536        self.assertEqual(
     537            self.app['faculties']['FAC1']['DEP1'].courses['CRS2'].title,
     538            'New Title')
    515539        shutil.rmtree(os.path.dirname(fin_file))
    516540        return
Note: See TracChangeset for help on using the changeset viewer.