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

Rename importers to processors.

File:
1 edited

Legend:

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

    r7912 r7933  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 """Unit tests for applicants-related data importers.
     18"""Unit tests for applicants-related data processors.
    1919"""
    2020import datetime
     
    2929from waeup.kofa.app import University
    3030from waeup.kofa.applicants.batching import (
    31     ApplicantsContainerImporter, ApplicantImporter)
     31    ApplicantsContainerProcessor, ApplicantProcessor)
    3232from waeup.kofa.applicants.container import ApplicantsContainer
    3333from waeup.kofa.applicants.applicant import Applicant
     
    6666    '\n')[0].split(',')
    6767
    68 class ApplicantsContainerImporterTest(FunctionalTestCase):
     68class ApplicantsContainerProcessorTest(FunctionalTestCase):
    6969
    7070    layer = FunctionalLayer
    7171
    7272    def setUp(self):
    73         super(ApplicantsContainerImporterTest, self).setUp()
     73        super(ApplicantsContainerProcessorTest, self).setUp()
    7474
    7575        # Setup a sample site for each test
     
    8585        self.app['applicants']['dp2011'] = self.container
    8686
    87         self.importer = ApplicantsContainerImporter()
     87        self.processor = ApplicantsContainerProcessor()
    8888        self.workdir = tempfile.mkdtemp()
    8989        self.csv_file = os.path.join(self.workdir, 'sampledata.csv')
     
    9393
    9494    def tearDown(self):
    95         super(ApplicantsContainerImporterTest, self).tearDown()
     95        super(ApplicantsContainerProcessorTest, self).tearDown()
    9696        shutil.rmtree(self.workdir)
    9797        shutil.rmtree(self.dc_root)
     
    101101    def test_interface(self):
    102102        # Make sure we fulfill the interface contracts.
    103         assert verifyObject(IBatchProcessor, self.importer) is True
     103        assert verifyObject(IBatchProcessor, self.processor) is True
    104104        assert verifyClass(
    105             IBatchProcessor, ApplicantsContainerImporter) is True
     105            IBatchProcessor, ApplicantsContainerProcessor) is True
    106106
    107107    def test_parentsExist(self):
    108         assert self.importer.parentsExist(None, dict()) is False
    109         assert self.importer.parentsExist(None, self.app) is True
     108        assert self.processor.parentsExist(None, dict()) is False
     109        assert self.processor.parentsExist(None, self.app) is True
    110110
    111111    def test_entryExists(self):
    112         assert self.importer.entryExists(
     112        assert self.processor.entryExists(
    113113            dict(code='REG_NONE'), self.app) is False
    114         assert self.importer.entryExists(
     114        assert self.processor.entryExists(
    115115            dict(code='dp2011'), self.app) is True
    116116
    117117    def test_getParent(self):
    118         parent = self.importer.getParent(None, self.app)
     118        parent = self.processor.getParent(None, self.app)
    119119        assert parent is self.app['applicants']
    120120
    121121    def test_getEntry(self):
    122         assert self.importer.getEntry(
     122        assert self.processor.getEntry(
    123123            dict(code='REG_NONE'), self.app) is None
    124         assert self.importer.getEntry(
     124        assert self.processor.getEntry(
    125125            dict(code='dp2011'), self.app) is self.container
    126126
    127127    def test_addEntry(self):
    128         self.importer.addEntry(
     128        self.processor.addEntry(
    129129            'New application', dict(code='dp2012'), self.app)
    130130        assert self.app['applicants']['dp2012'] == 'New application'
    131131
    132132    def test_delEntry(self):
    133         self.importer.delEntry(dict(code='dp2011'), self.app)
     133        self.processor.delEntry(dict(code='dp2011'), self.app)
    134134        assert 'dp2011' not in self.app['applicants'].keys()
    135135
     
    137137        # Do a real import
    138138        # see local sample_container.csv file for input
    139         num, num_warns, fin_file, fail_file = self.importer.doImport(
     139        num, num_warns, fin_file, fail_file = self.processor.doImport(
    140140            self.csv_file, APPS_CONTAINER_HEADER_FIELDS)
    141141        avail_containers = [x for x in self.app['applicants'].keys()]
     
    219219        return
    220220
    221 class ApplicantImporterTest(ApplicantImportExportSetup):
     221class ApplicantProcessorTest(ApplicantImportExportSetup):
    222222
    223223    layer = FunctionalLayer
    224224
    225225    def setUp(self):
    226         super(ApplicantImporterTest, self).setUp()
    227         self.importer = ApplicantImporter()
     226        super(ApplicantProcessorTest, self).setUp()
     227        self.processor = ApplicantProcessor()
    228228        self.csv_file = os.path.join(self.workdir, 'sample_applicant_data.csv')
    229229        self.csv_file_faulty = os.path.join(self.workdir,
     
    237237    def test_interface(self):
    238238        # Make sure we fulfill the interface contracts.
    239         assert verifyObject(IBatchProcessor, self.importer) is True
     239        assert verifyObject(IBatchProcessor, self.processor) is True
    240240        assert verifyClass(
    241             IBatchProcessor, ApplicantImporter) is True
     241            IBatchProcessor, ApplicantProcessor) is True
    242242
    243243    def test_entryExists(self):
    244         assert self.importer.entryExists(
     244        assert self.processor.entryExists(
    245245            dict(container_code='dp2011', application_number='999'),
    246246            self.app) is False
    247247
    248248    def test_getEntry(self):
    249         applicant = self.importer.getEntry(
     249        applicant = self.processor.getEntry(
    250250            dict(container_code='dp2011',
    251251                 application_number=self.application_number), self.app)
     
    254254    def test_addEntry(self):
    255255        new_applicant = Applicant()
    256         self.importer.addEntry(
     256        self.processor.addEntry(
    257257            new_applicant, dict(container_code='dp2011'), self.app)
    258258        assert len(self.app['applicants']['dp2011'].keys()) == 2
     
    261261        assert self.application_number in self.app[
    262262            'applicants']['dp2011'].keys()
    263         self.importer.delEntry(
     263        self.processor.delEntry(
    264264            dict(container_code='dp2011',
    265265                application_number=self.application_number), self.app)
     
    268268
    269269    def test_import(self):
    270         num, num_warns, fin_file, fail_file = self.importer.doImport(
     270        num, num_warns, fin_file, fail_file = self.processor.doImport(
    271271            self.csv_file, APPLICANT_HEADER_FIELDS)
    272272        self.assertEqual(num_warns,0)
     
    285285        # when in format xx/yy/zzzz as we cannot say whether it is
    286286        # meant as dd/mm/yyyy or mm/dd/yyyy. We therefore require yyyy-mm-dd
    287         num, num_warns, fin_file, fail_file = self.importer.doImport(
     287        num, num_warns, fin_file, fail_file = self.processor.doImport(
    288288            self.csv_file_faulty, APPLICANT_HEADER_FIELDS)
    289289        if fail_file is not None:
     
    300300
    301301    def test_import_update(self):
    302         num, num_warns, fin_file, fail_file = self.importer.doImport(
     302        num, num_warns, fin_file, fail_file = self.processor.doImport(
    303303            self.csv_file, APPLICANT_HEADER_FIELDS)
    304304        shutil.rmtree(os.path.dirname(fin_file))
    305         num, num_warns, fin_file, fail_file = self.importer.doImport(
     305        num, num_warns, fin_file, fail_file = self.processor.doImport(
    306306            self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'update')
    307307        self.assertEqual(num_warns,0)
     
    309309
    310310    def test_import_remove(self):
    311         num, num_warns, fin_file, fail_file = self.importer.doImport(
     311        num, num_warns, fin_file, fail_file = self.processor.doImport(
    312312            self.csv_file, APPLICANT_HEADER_FIELDS)
    313313        shutil.rmtree(os.path.dirname(fin_file))
    314         num, num_warns, fin_file, fail_file = self.importer.doImport(
     314        num, num_warns, fin_file, fail_file = self.processor.doImport(
    315315            self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'remove')
    316316        self.assertEqual(num_warns,0)
Note: See TracChangeset for help on using the changeset viewer.