Ignore:
Timestamp:
30 May 2011, 21:57:00 (14 years ago)
Author:
uli
Message:

First steps to make the copied batch-stuff work with regular applicants. Right now we only get more errors.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/batching.py

    r6250 r6251  
    2626from waeup.sirp.interfaces import IBatchProcessor
    2727from waeup.sirp.utils.batching import BatchProcessor
    28 from waeup.sirp.applicants.jambtables.interfaces import IApplicantPDEImportData
     28from waeup.sirp.applicants.interfaces import IApplicantsContainer
    2929
    30 class JAMBDataImporter(BatchProcessor):
    31     """An importer for applicants.
     30class ApplicantsContainerImporter(BatchProcessor):
     31    """An importer for applicants containers.
    3232    """
    3333    grok.implements(IBatchProcessor)
    3434    grok.provides(IBatchProcessor)
    3535    grok.context(Interface)
    36     util_name = 'application importer'
     36    util_name = 'applicants container importer'
    3737    grok.name(util_name)
    3838
    39     name = u'JAMB Data Importer'
     39    name = u'Applicants Container Importer'
    4040    mode = u'create'
    41     iface = IApplicantPDEImportData
     41    iface = IApplicantsContainer
    4242
    43     location_fields = ['reg_no',]
    44     factory_name = 'waeup.Applicant'
     43    location_fields = ['code',]
     44    factory_name = 'waeup.ApplicantContainer'
    4545
    4646    def parentsExist(self, row, site):
    47         return 'jambdata' in site.keys()
     47        return 'applicants' in site.keys()
    4848
    4949    def entryExists(self, row, site):
    50         return row['reg_no'] in site['jambdata'].keys()
     50        return row['code'] in site['applicants'].keys()
    5151
    5252    def getParent(self, row, site):
    53         return site['jambdata']
     53        return site['applicants']
    5454
    5555    def getEntry(self, row, site):
     
    5757            return None
    5858        parent = self.getParent(row, site)
    59         return parent.get(row['reg_no'])
     59        return parent.get(row['code'])
    6060
    6161    def addEntry(self, obj, row, site):
    6262        parent = self.getParent(row, site)
    63         reg_no = row['reg_no']
    64         parent[reg_no] = obj
     63        parent[row['code']] = obj
    6564        return
    6665
    6766    def delEntry(self, row, site):
    6867        parent = self.getParent(row, site)
    69         del parent[row['reg_no']]
     68        del parent[row['code']]
    7069        return
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_batching.py

    r6250 r6251  
    2020## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    2121##
    22 """Unit tests for the JAMB data importer.
     22"""Unit tests for applicants-related data importers.
    2323"""
    24 
    2524import grok
    2625import os
     
    2827import tempfile
    2928import unittest
     29from zope.app.testing.functional import FunctionalTestCase
    3030from zope.component.hooks import setSite, clearSite
    31 from zope.interface import verify
     31from zope.interface.verify import verifyClass, verifyObject
     32
     33from waeup.sirp.app import University
     34from waeup.sirp.applicants.batching import ApplicantsContainerImporter
     35from waeup.sirp.applicants.interfaces import IApplicantsContainer
     36from waeup.sirp.interfaces import DuplicationError
     37from waeup.sirp.testing import FunctionalLayer, doctestsuite_for_module
    3238from waeup.sirp.interfaces import IBatchProcessor
    33 from waeup.sirp.applicants.jambtables import JAMBDataImporter
     39
    3440
    3541# Sample data we can use in tests...
     
    4753        return object()
    4854
    49 class JAMBDataImporterTest(unittest.TestCase):
     55class ApplicantsContainerImporterTest(unittest.TestCase):
    5056
    5157    def setUp(self):
    52         self.importer = JAMBDataImporter()
     58        self.importer = ApplicantsContainerImporter()
    5359        self.site1 = dict(
    5460            jambdata = {
     
    6874    def test_interface(self):
    6975        """Make sure we fulfill the interface contracts."""
    70         assert verify.verifyObject(IBatchProcessor, self.importer) is True
    71         assert verify.verifyClass(IBatchProcessor, JAMBDataImporter) is True
     76        assert verifyObject(IBatchProcessor, self.importer) is True
     77        assert verifyClass(
     78            IBatchProcessor, ApplicantsContainerImporter) is True
    7279
    7380    def test_parentsExist(self):
     
    120127    suite = unittest.TestSuite()
    121128    for testcase in [
    122         JAMBDataImporterTest,
     129        ApplicantsContainerImporterTest,
    123130        ]:
    124131        suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
Note: See TracChangeset for help on using the changeset viewer.