Changeset 9272


Ignore:
Timestamp:
2 Oct 2012, 14:01:38 (12 years ago)
Author:
uli
Message:

Shorten some overlong lines and remove temporary dirs remaining from
doImport() calls.

File:
1 edited

Legend:

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

    r9151 r9272  
    9595
    9696STUDENT_SAMPLE_DATA_MIGRATION = open(
    97     os.path.join(os.path.dirname(__file__), 'sample_student_data_migration.csv'),
     97    os.path.join(os.path.dirname(__file__),
     98                 'sample_student_data_migration.csv'),
    9899    'rb').read()
    99100
     
    102103
    103104STUDENT_SAMPLE_DATA_DUPLICATES = open(
    104     os.path.join(os.path.dirname(__file__), 'sample_student_data_duplicates.csv'),
     105    os.path.join(os.path.dirname(__file__),
     106                 'sample_student_data_duplicates.csv'),
    105107    'rb').read()
    106108
     
    256258
    257259        self.processor = StudentProcessor()
    258         self.workdir = tempfile.mkdtemp()
    259260        self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv')
    260261        self.csv_file_update = os.path.join(
     
    377378        self.assertEqual(self.app['students']['X666666'].state,'admitted')
    378379        # state has not changed
    379         self.assertEqual(self.app['students']['Y777777'].state,'courses validated')
     380        self.assertEqual(self.app['students']['Y777777'].state,
     381                         'courses validated')
    380382        shutil.rmtree(os.path.dirname(fin_file))
    381383
     
    411413            self.csv_file_update3, STUDENT_HEADER_FIELDS_UPDATE3, 'update')
    412414        content = open(fail_file).read()
     415        shutil.rmtree(os.path.dirname(fin_file))
    413416        self.assertEqual(
    414417            content,
     
    546549    def test_checkUpdateRequirements(self):
    547550        # Make sure that pg students can't be updated with wrong transition.
    548         err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     551        err = self.processor.checkUpdateRequirements(
     552            self.student['studycourse'],
    549553            dict(reg_number='1', current_level='100'), self.app)
    550554        self.assertTrue(err is None)
    551555        # Since row has passed the converter, current_level is an integer.
    552         err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     556        err = self.processor.checkUpdateRequirements(
     557            self.student['studycourse'],
    553558            dict(reg_number='1', current_level=999), self.app)
    554559        self.assertTrue(err is None)
    555560        IWorkflowState(self.student).setState('returning')
    556         err = self.processor.checkUpdateRequirements(self.student['studycourse'],
     561        err = self.processor.checkUpdateRequirements(
     562            self.student['studycourse'],
    557563            dict(reg_number='1', current_level=999), self.app)
    558564        self.assertEqual(err, 'Not a pg student.')
     
    600606            self.csv_file, VERDICT_HEADER_FIELDS,'update')
    601607        self.assertEqual(num_warns,3)
    602         studycourse = self.processor.getEntry(dict(matric_number='100000'), self.app)
    603         student = self.processor.getParent(dict(matric_number='100000'), self.app)
     608        studycourse = self.processor.getEntry(dict(matric_number='100000'),
     609                                              self.app)
     610        student = self.processor.getParent(
     611            dict(matric_number='100000'), self.app)
    604612        self.assertEqual(studycourse.current_verdict, 'A')
    605613        self.assertEqual(student.state, 'returning')
     
    688696        num, num_warns, fin_file, fail_file = self.processor.doImport(
    689697            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
     698        shutil.rmtree(os.path.dirname(fin_file))
    690699        num, num_warns, fin_file, fail_file = self.processor.doImport(
    691700            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'update')
     
    713722        self.app['faculties']['fac1']['dep1'].courses.addCourse(
    714723            self.course)
    715         self.app['faculties']['fac1']['dep1'].certificates['CERT1'].addCertCourse(
     724        self.app['faculties']['fac1']['dep1'].certificates[
     725            'CERT1'].addCertCourse(
    716726            self.course, level=100)
    717727
     
    761771        self.assertEqual(num_warns,2)
    762772        assert self.processor.entryExists(
    763             dict(reg_number='1', level='100', code='COURSE1'), self.app) is True
     773            dict(reg_number='1', level='100', code='COURSE1'),
     774            self.app) is True
    764775        courseticket = self.processor.getEntry(
    765776            dict(reg_number='1', level='100', code='COURSE1'), self.app)
    766         self.assertEqual(courseticket.__parent__.__parent__.certificate.code, u'CERT1')
     777        self.assertEqual(courseticket.__parent__.__parent__.certificate.code,
     778                         u'CERT1')
    767779        self.assertEqual(courseticket.score, 1)
    768780        self.assertEqual(courseticket.mandatory, True)
     
    789801        num, num_warns, fin_file, fail_file = self.processor.doImport(
    790802            self.csv_file, COURSETICKET_HEADER_FIELDS,'create')
     803        shutil.rmtree(os.path.dirname(fin_file))
    791804        num, num_warns, fin_file, fail_file = self.processor.doImport(
    792805            self.csv_file, COURSETICKET_HEADER_FIELDS,'update')
     
    800813        num, num_warns, fin_file, fail_file = self.processor.doImport(
    801814            self.csv_file, COURSETICKET_HEADER_FIELDS,'create')
     815        shutil.rmtree(os.path.dirname(fin_file))
    802816        assert self.processor.entryExists(
    803817            dict(reg_number='1', level='100', code='COURSE1'), self.app) is True
     
    946960        num, num_warns, fin_file, fail_file = self.processor.doImport(
    947961            self.csv_file, PAYMENT_HEADER_FIELDS,'create')
     962        shutil.rmtree(os.path.dirname(fin_file))
    948963        num, num_warns, fin_file, fail_file = self.processor.doImport(
    949964            self.csv_file, PAYMENT_HEADER_FIELDS,'update')
     
    954969        num, num_warns, fin_file, fail_file = self.processor.doImport(
    955970            self.csv_file, PAYMENT_HEADER_FIELDS,'create')
     971        shutil.rmtree(os.path.dirname(fin_file))
    956972        num, num_warns, fin_file, fail_file = self.processor.doImport(
    957973            self.csv_file, PAYMENT_HEADER_FIELDS,'remove')
Note: See TracChangeset for help on using the changeset viewer.