Ignore:
Timestamp:
21 Mar 2012, 13:42:00 (13 years ago)
Author:
Henrik Bettermann
Message:

Rename importers to processors.

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

Legend:

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

    r7811 r7933  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 """Unit tests for students-related data importers.
     18"""Unit tests for students-related data processors.
    1919"""
    2020import os
     
    9595    '\n')[0].split(',')
    9696
    97 class StudentImporterTest(FunctionalTestCase):
     97class StudentProcessorTest(FunctionalTestCase):
    9898
    9999    layer = FunctionalLayer
    100100
    101101    def setUp(self):
    102         super(StudentImporterTest, self).setUp()
     102        super(StudentProcessorTest, self).setUp()
    103103        # Setup a sample site for each test
    104104        app = University()
     
    124124        self.app['students'].addStudent(student)
    125125        self.student = self.app['students'][student.student_id]
    126         self.importer = StudentProcessor()
     126        self.processor = StudentProcessor()
    127127        self.workdir = tempfile.mkdtemp()
    128128        self.csv_file = os.path.join(self.workdir, 'sample_student_data.csv')
     
    139139
    140140    def tearDown(self):
    141         super(StudentImporterTest, self).tearDown()
     141        super(StudentProcessorTest, self).tearDown()
    142142        shutil.rmtree(self.workdir)
    143143        shutil.rmtree(self.dc_root)
     
    147147    def test_interface(self):
    148148        # Make sure we fulfill the interface contracts.
    149         assert verifyObject(IBatchProcessor, self.importer) is True
     149        assert verifyObject(IBatchProcessor, self.processor) is True
    150150        assert verifyClass(
    151151            IBatchProcessor, StudentProcessor) is True
    152152
    153153    def test_parentsExist(self):
    154         self.assertFalse(self.importer.parentsExist(None, dict()))
    155         self.assertTrue(self.importer.parentsExist(None, self.app))
     154        self.assertFalse(self.processor.parentsExist(None, dict()))
     155        self.assertTrue(self.processor.parentsExist(None, self.app))
    156156
    157157    def test_entryExists(self):
    158         assert self.importer.entryExists(
     158        assert self.processor.entryExists(
    159159            dict(student_id='ID_NONE'), self.app) is False
    160         assert self.importer.entryExists(
     160        assert self.processor.entryExists(
    161161            dict(reg_number='123'), self.app) is True
    162162
    163163    def test_getParent(self):
    164         parent = self.importer.getParent(None, self.app)
     164        parent = self.processor.getParent(None, self.app)
    165165        assert parent is self.app['students']
    166166
    167167    def test_getEntry(self):
    168         assert self.importer.getEntry(
     168        assert self.processor.getEntry(
    169169            dict(student_id='ID_NONE'), self.app) is None
    170         assert self.importer.getEntry(
     170        assert self.processor.getEntry(
    171171            dict(student_id=self.student.student_id), self.app) is self.student
    172172
    173173    def test_addEntry(self):
    174174        new_student = Student()
    175         self.importer.addEntry(
     175        self.processor.addEntry(
    176176            new_student, dict(), self.app)
    177177        assert len(self.app['students'].keys()) == 2
    178178
    179179    def test_checkConversion(self):
    180         errs, inv_errs, conv_dict = self.importer.checkConversion(
     180        errs, inv_errs, conv_dict = self.processor.checkConversion(
    181181            dict(reg_number='1', reg_state='admitted'))
    182182        self.assertEqual(len(errs),0)
    183         errs, inv_errs, conv_dict = self.importer.checkConversion(
     183        errs, inv_errs, conv_dict = self.processor.checkConversion(
    184184            dict(reg_number='1', reg_state=''))
    185185        self.assertEqual(len(errs),1)
    186186        self.assertTrue(('reg_state', 'no value provided') in errs)
    187         errs, inv_errs, conv_dict = self.importer.checkConversion(
     187        errs, inv_errs, conv_dict = self.processor.checkConversion(
    188188            dict(reg_number='1', reg_state='nonsense'))
    189189        self.assertEqual(len(errs),1)
     
    192192    def test_delEntry(self):
    193193        assert self.student.student_id in self.app['students'].keys()
    194         self.importer.delEntry(
     194        self.processor.delEntry(
    195195            dict(reg_number=self.student.reg_number), self.app)
    196196        assert self.student.student_id not in self.app['students'].keys()
    197197
    198198    def test_import(self):
    199         num, num_warns, fin_file, fail_file = self.importer.doImport(
     199        num, num_warns, fin_file, fail_file = self.processor.doImport(
    200200            self.csv_file, STUDENT_HEADER_FIELDS)
    201201        self.assertEqual(num_warns,0)
     
    205205
    206206    def test_import_update(self):
    207         num, num_warns, fin_file, fail_file = self.importer.doImport(
     207        num, num_warns, fin_file, fail_file = self.processor.doImport(
    208208            self.csv_file, STUDENT_HEADER_FIELDS)
    209209        shutil.rmtree(os.path.dirname(fin_file))
    210         num, num_warns, fin_file, fail_file = self.importer.doImport(
     210        num, num_warns, fin_file, fail_file = self.processor.doImport(
    211211            self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'update')
    212212        self.assertEqual(num_warns,0)
     
    214214
    215215    def test_import_update2(self):
    216         num, num_warns, fin_file, fail_file = self.importer.doImport(
     216        num, num_warns, fin_file, fail_file = self.processor.doImport(
    217217            self.csv_file, STUDENT_HEADER_FIELDS)
    218218        shutil.rmtree(os.path.dirname(fin_file))
    219         num, num_warns, fin_file, fail_file = self.importer.doImport(
     219        num, num_warns, fin_file, fail_file = self.processor.doImport(
    220220            self.csv_file_update2, STUDENT_HEADER_FIELDS_UPDATE2, 'update')
    221221        self.assertEqual(num_warns,0)
     
    223223
    224224    def test_import_remove(self):
    225         num, num_warns, fin_file, fail_file = self.importer.doImport(
     225        num, num_warns, fin_file, fail_file = self.processor.doImport(
    226226            self.csv_file, STUDENT_HEADER_FIELDS)
    227227        shutil.rmtree(os.path.dirname(fin_file))
    228         num, num_warns, fin_file, fail_file = self.importer.doImport(
     228        num, num_warns, fin_file, fail_file = self.processor.doImport(
    229229            self.csv_file_update, STUDENT_HEADER_FIELDS_UPDATE, 'remove')
    230230        self.assertEqual(num_warns,0)
     
    232232
    233233    def test_import_migration_data(self):
    234         num, num_warns, fin_file, fail_file = self.importer.doImport(
     234        num, num_warns, fin_file, fail_file = self.processor.doImport(
    235235            self.csv_file_migration, STUDENT_HEADER_FIELDS_MIGRATION)
    236236        self.assertEqual(num_warns,2)
     
    251251
    252252
    253 class StudentStudyCourseImporterTest(FunctionalTestCase):
     253class StudentStudyCourseProcessorTest(FunctionalTestCase):
    254254
    255255    layer = FunctionalLayer
    256256
    257257    def setUp(self):
    258         super(StudentStudyCourseImporterTest, self).setUp()
     258        super(StudentStudyCourseProcessorTest, self).setUp()
    259259        self.dc_root = tempfile.mkdtemp()
    260260        self.workdir = tempfile.mkdtemp()
     
    283283            self.certificate)
    284284
    285         self.importer = StudentStudyCourseProcessor()
     285        self.processor = StudentStudyCourseProcessor()
    286286        self.csv_file = os.path.join(
    287287            self.workdir, 'sample_studycourse_data.csv')
     
    290290
    291291    def tearDown(self):
    292         super(StudentStudyCourseImporterTest, self).tearDown()
     292        super(StudentStudyCourseProcessorTest, self).tearDown()
    293293        shutil.rmtree(self.workdir)
    294294        shutil.rmtree(self.dc_root)
     
    298298    def test_interface(self):
    299299        # Make sure we fulfill the interface contracts.
    300         assert verifyObject(IBatchProcessor, self.importer) is True
     300        assert verifyObject(IBatchProcessor, self.processor) is True
    301301        assert verifyClass(
    302302            IBatchProcessor, StudentStudyCourseProcessor) is True
    303303
    304304    def test_entryExists(self):
    305         assert self.importer.entryExists(
     305        assert self.processor.entryExists(
    306306            dict(reg_number='REG_NONE'), self.app) is False
    307         assert self.importer.entryExists(
     307        assert self.processor.entryExists(
    308308            dict(reg_number='1'), self.app) is True
    309309
    310310    def test_getEntry(self):
    311         student = self.importer.getEntry(
     311        student = self.processor.getEntry(
    312312            dict(reg_number='1'), self.app).__parent__
    313313        self.assertEqual(student.reg_number,'1')
    314314
    315315    def test_checkConversion(self):
    316         errs, inv_errs, conv_dict = self.importer.checkConversion(
     316        errs, inv_errs, conv_dict = self.processor.checkConversion(
    317317            dict(reg_number='1', certificate='CERT1', current_level='200'))
    318318        self.assertEqual(len(errs),0)
    319         errs, inv_errs, conv_dict = self.importer.checkConversion(
     319        errs, inv_errs, conv_dict = self.processor.checkConversion(
    320320            dict(reg_number='1', certificate='CERT999'))
    321321        self.assertEqual(len(errs),1)
    322322        self.assertTrue(('certificate', u'Invalid value') in errs)
    323         errs, inv_errs, conv_dict = self.importer.checkConversion(
     323        errs, inv_errs, conv_dict = self.processor.checkConversion(
    324324            dict(reg_number='1', certificate='CERT1', current_level='100'))
    325325        self.assertEqual(len(errs),1)
    326326        self.assertTrue(('current_level','not in range') in errs)
    327327        # If we import only current_level, no conversion checking is done.
    328         errs, inv_errs, conv_dict = self.importer.checkConversion(
     328        errs, inv_errs, conv_dict = self.processor.checkConversion(
    329329            dict(reg_number='1', current_level='100'))
    330330        self.assertEqual(len(errs),0)
    331331
    332332    def test_import(self):
    333         num, num_warns, fin_file, fail_file = self.importer.doImport(
     333        num, num_warns, fin_file, fail_file = self.processor.doImport(
    334334            self.csv_file, STUDYCOURSE_HEADER_FIELDS,'update')
    335335        self.assertEqual(num_warns,1)
    336         studycourse = self.importer.getEntry(dict(reg_number='1'), self.app)
     336        studycourse = self.processor.getEntry(dict(reg_number='1'), self.app)
    337337        self.assertEqual(studycourse.certificate.code, u'CERT1')
    338338        shutil.rmtree(os.path.dirname(fin_file))
    339339
    340 class StudentStudyLevelImporterTest(FunctionalTestCase):
     340class StudentStudyLevelProcessorTest(FunctionalTestCase):
    341341
    342342    layer = FunctionalLayer
    343343
    344344    def setUp(self):
    345         super(StudentStudyLevelImporterTest, self).setUp()
     345        super(StudentStudyLevelProcessorTest, self).setUp()
    346346        self.dc_root = tempfile.mkdtemp()
    347347        self.workdir = tempfile.mkdtemp()
     
    374374            self.workdir, 'sample_studycourse_data.csv')
    375375        open(studycourse_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA)
    376         importer = StudentStudyCourseProcessor()
    377         num, num_warns, fin_file, fail_file = importer.doImport(
     376        processor = StudentStudyCourseProcessor()
     377        num, num_warns, fin_file, fail_file = processor.doImport(
    378378            studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update')
    379379        shutil.rmtree(os.path.dirname(fin_file))
    380380
    381         self.importer = StudentStudyLevelProcessor()
     381        self.processor = StudentStudyLevelProcessor()
    382382        self.csv_file = os.path.join(
    383383            self.workdir, 'sample_studylevel_data.csv')
     
    385385
    386386    def tearDown(self):
    387         super(StudentStudyLevelImporterTest, self).tearDown()
     387        super(StudentStudyLevelProcessorTest, self).tearDown()
    388388        shutil.rmtree(self.workdir)
    389389        shutil.rmtree(self.dc_root)
     
    393393    def test_interface(self):
    394394        # Make sure we fulfill the interface contracts.
    395         assert verifyObject(IBatchProcessor, self.importer) is True
     395        assert verifyObject(IBatchProcessor, self.processor) is True
    396396        assert verifyClass(
    397397            IBatchProcessor, StudentStudyLevelProcessor) is True
    398398
    399399    def test_checkConversion(self):
    400         errs, inv_errs, conv_dict = self.importer.checkConversion(
     400        errs, inv_errs, conv_dict = self.processor.checkConversion(
    401401            dict(reg_number='1', level='220'))
    402402        self.assertEqual(len(errs),0)
    403         errs, inv_errs, conv_dict = self.importer.checkConversion(
     403        errs, inv_errs, conv_dict = self.processor.checkConversion(
    404404            dict(reg_number='1', level='900'))
    405405        self.assertEqual(len(errs),1)
    406406        self.assertTrue(('level','no valid integer') in errs)
    407         errs, inv_errs, conv_dict = self.importer.checkConversion(
     407        errs, inv_errs, conv_dict = self.processor.checkConversion(
    408408            dict(reg_number='1', level='xyz'))
    409409        self.assertEqual(len(errs),1)
     
    411411
    412412    def test_import(self):
    413         num, num_warns, fin_file, fail_file = self.importer.doImport(
     413        num, num_warns, fin_file, fail_file = self.processor.doImport(
    414414            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
    415415        self.assertEqual(num_warns,2)
    416         assert self.importer.entryExists(
     416        assert self.processor.entryExists(
    417417            dict(reg_number='1', level='100'), self.app) is True
    418         studylevel = self.importer.getEntry(
     418        studylevel = self.processor.getEntry(
    419419            dict(reg_number='1', level='100'), self.app)
    420420        self.assertEqual(studylevel.__parent__.certificate.code, u'CERT1')
     
    425425       
    426426
    427 class CourseTicketImporterTest(FunctionalTestCase):
     427class CourseTicketProcessorTest(FunctionalTestCase):
    428428
    429429    layer = FunctionalLayer
    430430
    431431    def setUp(self):
    432         super(CourseTicketImporterTest, self).setUp()
     432        super(CourseTicketProcessorTest, self).setUp()
    433433        self.dc_root = tempfile.mkdtemp()
    434434        self.workdir = tempfile.mkdtemp()
     
    470470            self.workdir, 'sample_studycourse_data.csv')
    471471        open(studycourse_file, 'wb').write(STUDYCOURSE_SAMPLE_DATA)
    472         importer = StudentStudyCourseProcessor()
    473         num, num_warns, fin_file, fail_file = importer.doImport(
     472        processor = StudentStudyCourseProcessor()
     473        num, num_warns, fin_file, fail_file = processor.doImport(
    474474            studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update')
    475475        shutil.rmtree(os.path.dirname(fin_file))
    476476
    477477        # Import study levels
    478         importer = StudentStudyLevelProcessor()
     478        processor = StudentStudyLevelProcessor()
    479479        studylevel_file = os.path.join(
    480480            self.workdir, 'sample_studylevel_data.csv')
    481481        open(studylevel_file, 'wb').write(STUDYLEVEL_SAMPLE_DATA)
    482         num, num_warns, fin_file, fail_file = importer.doImport(
     482        num, num_warns, fin_file, fail_file = processor.doImport(
    483483            studylevel_file, STUDYLEVEL_HEADER_FIELDS,'create')
    484484        shutil.rmtree(os.path.dirname(fin_file))
    485485
    486         self.importer = CourseTicketProcessor()
     486        self.processor = CourseTicketProcessor()
    487487        self.csv_file = os.path.join(
    488488            self.workdir, 'sample_courseticket_data.csv')
     
    490490
    491491    def tearDown(self):
    492         super(CourseTicketImporterTest, self).tearDown()
     492        super(CourseTicketProcessorTest, self).tearDown()
    493493        shutil.rmtree(self.workdir)
    494494        shutil.rmtree(self.dc_root)
     
    498498    def test_interface(self):
    499499        # Make sure we fulfill the interface contracts.
    500         assert verifyObject(IBatchProcessor, self.importer) is True
     500        assert verifyObject(IBatchProcessor, self.processor) is True
    501501        assert verifyClass(
    502502            IBatchProcessor, CourseTicketProcessor) is True
    503503
    504504    def test_checkConversion(self):
    505         errs, inv_errs, conv_dict = self.importer.checkConversion(
     505        errs, inv_errs, conv_dict = self.processor.checkConversion(
    506506            dict(reg_number='1', code='COURSE1', level='220'))
    507507        self.assertEqual(len(errs),0)
    508         errs, inv_errs, conv_dict = self.importer.checkConversion(
     508        errs, inv_errs, conv_dict = self.processor.checkConversion(
    509509            dict(reg_number='1', code='COURSE2', level='220'))
    510510        self.assertEqual(len(errs),1)
     
    513513    def test_import(self):
    514514
    515         num, num_warns, fin_file, fail_file = self.importer.doImport(
     515        num, num_warns, fin_file, fail_file = self.processor.doImport(
    516516            self.csv_file, COURSETICKET_HEADER_FIELDS,'create')
    517517
    518518        self.assertEqual(num_warns,2)
    519         assert self.importer.entryExists(
     519        assert self.processor.entryExists(
    520520            dict(reg_number='1', level='100', code='COURSE1'), self.app) is True
    521         courseticket = self.importer.getEntry(
     521        courseticket = self.processor.getEntry(
    522522            dict(reg_number='1', level='100', code='COURSE1'), self.app)
    523523        self.assertEqual(courseticket.__parent__.__parent__.certificate.code, u'CERT1')
     
    533533        shutil.rmtree(os.path.dirname(fin_file))
    534534
    535 class PaymentImporterTest(FunctionalTestCase):
     535class PaymentProcessorTest(FunctionalTestCase):
    536536
    537537    layer = FunctionalLayer
    538538
    539539    def setUp(self):
    540         super(PaymentImporterTest, self).setUp()
     540        super(PaymentProcessorTest, self).setUp()
    541541        self.dc_root = tempfile.mkdtemp()
    542542        self.workdir = tempfile.mkdtemp()
     
    566566        shutil.rmtree(os.path.dirname(fin_file))
    567567
    568         self.importer = StudentOnlinePaymentProcessor()
     568        self.processor = StudentOnlinePaymentProcessor()
    569569        self.csv_file = os.path.join(
    570570            self.workdir, 'sample_payment_data.csv')
     
    572572
    573573    def tearDown(self):
    574         super(PaymentImporterTest, self).tearDown()
     574        super(PaymentProcessorTest, self).tearDown()
    575575        shutil.rmtree(self.workdir)
    576576        shutil.rmtree(self.dc_root)
     
    580580    def test_interface(self):
    581581        # Make sure we fulfill the interface contracts.
    582         assert verifyObject(IBatchProcessor, self.importer) is True
     582        assert verifyObject(IBatchProcessor, self.processor) is True
    583583        assert verifyClass(
    584584            IBatchProcessor, StudentOnlinePaymentProcessor) is True
    585585
    586586    def test_getEntry(self):
    587         assert self.importer.getEntry(
     587        assert self.processor.getEntry(
    588588            dict(student_id='ID_NONE', p_id='nonsense'), self.app) is None
    589         assert self.importer.getEntry(
     589        assert self.processor.getEntry(
    590590            dict(student_id=self.student.student_id, p_id='p123'),
    591591            self.app) is self.student['payments']['p123']
    592         assert self.importer.getEntry(
     592        assert self.processor.getEntry(
    593593            dict(student_id=self.student.student_id, p_id='XXXXXX123'),
    594594            self.app) is self.student['payments']['p123']
     
    598598        payment1 = createObject(u'waeup.StudentOnlinePayment')
    599599        payment1.p_id = 'p234'
    600         self.importer.addEntry(
     600        self.processor.addEntry(
    601601            payment1, dict(student_id=self.student.student_id, p_id='p234'),
    602602            self.app)
     
    606606        payment1.p_id = 'nonsense'
    607607        # payment1.p_id will be replaced if p_id doesn't start with 'p'
    608         self.importer.addEntry(
     608        self.processor.addEntry(
    609609            payment2, dict(student_id=self.student.student_id, p_id='XXXXXX456'),
    610610            self.app)
     
    613613
    614614    def test_checkConversion(self):
    615         errs, inv_errs, conv_dict = self.importer.checkConversion(
     615        errs, inv_errs, conv_dict = self.processor.checkConversion(
    616616            dict(reg_number='1', p_id='3816951266236341955'))
    617617        self.assertEqual(len(errs),0)
    618         errs, inv_errs, conv_dict = self.importer.checkConversion(
     618        errs, inv_errs, conv_dict = self.processor.checkConversion(
    619619            dict(reg_number='1', p_id='p1266236341955'))
    620620        self.assertEqual(len(errs),0)
    621         errs, inv_errs, conv_dict = self.importer.checkConversion(
     621        errs, inv_errs, conv_dict = self.processor.checkConversion(
    622622            dict(reg_number='1', p_id='nonsense'))
    623623        self.assertEqual(len(errs),1)
    624624        timestamp = "%d" % int(time()*1000)
    625625        p_id = "p%s" % timestamp
    626         errs, inv_errs, conv_dict = self.importer.checkConversion(
     626        errs, inv_errs, conv_dict = self.processor.checkConversion(
    627627            dict(reg_number='1', p_id=p_id))
    628628        self.assertEqual(len(errs),0)
    629629
    630630    def test_import(self):
    631         num, num_warns, fin_file, fail_file = self.importer.doImport(
     631        num, num_warns, fin_file, fail_file = self.processor.doImport(
    632632            self.csv_file, PAYMENT_HEADER_FIELDS,'create')
    633633        self.assertEqual(num_warns,0)
    634         payment = self.importer.getEntry(dict(reg_number='1',
     634        payment = self.processor.getEntry(dict(reg_number='1',
    635635            p_id='p1290797973744'), self.app)
    636636        self.assertEqual(payment.p_id, 'p1290797973744')
     
    642642    suite = unittest.TestSuite()
    643643    for testcase in [
    644         StudentImporterTest,StudentStudyCourseImporterTest,
    645         StudentStudyLevelImporterTest,CourseTicketImporterTest,
    646         PaymentImporterTest,]:
     644        StudentProcessorTest,StudentStudyCourseProcessorTest,
     645        StudentStudyLevelProcessorTest,CourseTicketProcessorTest,
     646        PaymentProcessorTest,]:
    647647        suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
    648648                testcase
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r7887 r7933  
    743743        importerselect = self.browser.getControl(name='importer')
    744744        modeselect = self.browser.getControl(name='mode')
    745         importerselect.getControl('Student Importer').selected = True
     745        importerselect.getControl('Student Processor').selected = True
    746746        modeselect.getControl(value='create').selected = True
    747747        self.browser.getControl('Proceed to step 3').click()
     
    770770        modeselect = self.browser.getControl(name='mode')
    771771        importerselect.getControl(
    772             'StudentStudyCourse Importer (update only)').selected = True
     772            'StudentStudyCourse Processor (update only)').selected = True
    773773        modeselect.getControl(value='create').selected = True
    774774        self.browser.getControl('Proceed to step 3').click()
Note: See TracChangeset for help on using the changeset viewer.