Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_batching.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_batching.py	(revision 6251)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_batching.py	(revision 6252)
@@ -33,4 +33,5 @@
 from waeup.sirp.app import University
 from waeup.sirp.applicants.batching import ApplicantsContainerImporter
+from waeup.sirp.applicants.container import ApplicantsContainer
 from waeup.sirp.applicants.interfaces import IApplicantsContainer
 from waeup.sirp.interfaces import DuplicationError
@@ -40,38 +41,47 @@
 
 # Sample data we can use in tests...
-JAMB_SAMPLE_DATA = '''reg_no,fst_sit_fname,lastname,firstname,middlenames,sex,date_of_birth,jamb_state,jamb_lga,course1,screening_date,screening_venue,entry_session,screening_type,ignore_this_col
-91100546DD,ISUOSUO MOSES ODOMERO,ISUOSUO,MOSES,ODOMERO,M,25/5/1982,DEL,ISO-S,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde,blah
-91111834CC,DURUIHEOMA AUGUSTINA ADANNA,DURUIHEOMA,AUGUSTINA,ADANNA,F,15/4/1986,IMO,MBAIT,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde,blah
-91109351AC,ARISERE EBIKEBUNA COMFORT,ARISERE,EBIKEBUNA,COMFORT,F,6/1/1984,EDO,OV-SW,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde,blah
-'''
+APPS_CONTAINER_SAMPLE_DATA = open(
+    os.path.join(os.path.dirname(__file__), 'sample_container_data.csv'),
+    'rb').read()
 
 # The header fields of the above CSV snippet
-HEADER_FIELDS = JAMB_SAMPLE_DATA.split('\n')[0].split(',')
+APPS_CONTAINER_HEADER_FIELDS = APPS_CONTAINER_SAMPLE_DATA.split(
+    '\n')[0].split(',')
 
-class FakeSite(dict):
-    def getSiteManager(self):
-        return object()
+class ApplicantsContainerImporterTest(FunctionalTestCase):
 
-class ApplicantsContainerImporterTest(unittest.TestCase):
+    layer = FunctionalLayer
 
     def setUp(self):
+        super(ApplicantsContainerImporterTest, self).setUp()
+
+        # Setup a sample site for each test
+        app = University()
+        self.dc_root = tempfile.mkdtemp()
+        app['datacenter'].setStoragePath(self.dc_root)
+
+        # Prepopulate the ZODB...
+        self.getRootFolder()['app'] = app
+        self.app = self.getRootFolder()['app']
+        self.container = ApplicantsContainer()
+        self.container.code = u'dp2011'
+        self.app['applicants']['dp2011'] = self.container
+
         self.importer = ApplicantsContainerImporter()
-        self.site1 = dict(
-            jambdata = {
-                'REG_NO_1': 'Application1',
-                }
-            )
         self.workdir = tempfile.mkdtemp()
         self.csv_file = os.path.join(self.workdir, 'sampledata.csv')
-        open(self.csv_file, 'wb').write(JAMB_SAMPLE_DATA)
+        open(self.csv_file, 'wb').write(APPS_CONTAINER_SAMPLE_DATA)
+        setSite(self.app)
         return
 
     def tearDown(self):
+        super(ApplicantsContainerImporterTest, self).tearDown()
         shutil.rmtree(self.workdir)
+        shutil.rmtree(self.dc_root)
         clearSite()
         return
 
     def test_interface(self):
-        """Make sure we fulfill the interface contracts."""
+        # Make sure we fulfill the interface contracts.
         assert verifyObject(IBatchProcessor, self.importer) is True
         assert verifyClass(
@@ -80,47 +90,44 @@
     def test_parentsExist(self):
         assert self.importer.parentsExist(None, dict()) is False
-        assert self.importer.parentsExist(None, self.site1) is True
+        assert self.importer.parentsExist(None, self.app) is True
 
     def test_entryExists(self):
         assert self.importer.entryExists(
-            dict(reg_no='REG_NONE'), self.site1) is False
+            dict(code='REG_NONE'), self.app) is False
         assert self.importer.entryExists(
-            dict(reg_no='REG_NO_1'), self.site1) is True
+            dict(code='dp2011'), self.app) is True
 
     def test_getParent(self):
-        parent = self.importer.getParent(None, self.site1)
-        assert parent is self.site1['jambdata']
+        parent = self.importer.getParent(None, self.app)
+        assert parent is self.app['applicants']
 
     def test_getEntry(self):
         assert self.importer.getEntry(
-            dict(reg_no='REG_NONE'), self.site1) is None
+            dict(code='REG_NONE'), self.app) is None
         assert self.importer.getEntry(
-            dict(reg_no='REG_NO_1'), self.site1) == 'Application1'
+            dict(code='dp2011'), self.app) is self.container
 
     def test_addEntry(self):
         self.importer.addEntry(
-            'New application', dict(reg_no='REG_NO_99'), self.site1)
-        assert self.site1['jambdata']['REG_NO_99'] == 'New application'
+            'New application', dict(code='dp2012'), self.app)
+        assert self.app['applicants']['dp2012'] == 'New application'
 
     def test_delEntry(self):
-        self.importer.delEntry(dict(reg_no='REG_NO_1'), self.site1)
-        assert 'REG_NO_1' not in self.site1['jambdata'].keys()
+        self.importer.delEntry(dict(code='dp2011'), self.app)
+        assert 'dp2011' not in self.app['applicants'].keys()
 
     def test_import(self):
         # Do a real import
-        # The following modules register important components for import
-        # Registers converters...
-        grok.testing.grok('waeup.sirp.utils.converters')
-        # Registers the Applicant factory...
-        grok.testing.grok('waeup.sirp.applicants.applicants')
+        self.importer.doImport(
+            self.csv_file, APPS_CONTAINER_HEADER_FIELDS)
+        #print self.workdir
+        #import pdb; pdb.set_trace()
 
-        # Create a fake site to store datasets in...
-        site = FakeSite()
-        # The site must have a 'jambdata' entry...
-        site['jambdata'] = dict()
-        # Set the fake site as 'current' site object...
-        setSite(site)
-        self.importer.doImport(self.csv_file, HEADER_FIELDS)
-        self.assertTrue(u'91100546DD' in site['jambdata'].keys())
+        # This currently gives:
+        #
+        # ac_prefix,code,application_category,provider,prefix,year,--ERRORS--
+        # APP,CODE1,app,base,app,2013,"conversion error: field application_category: <type 'exceptions.LookupError'> LookupError('app',) / conversion error: field provider: <type 'exceptions.TypeError'> TypeError('unhashable type',)"
+        # DPP,CODE2,dp,base,app,2013,"conversion error: field application_category: <type 'exceptions.LookupError'> LookupError('dp',) / conversion error: field provider: <type 'exceptions.TypeError'> TypeError('unhashable type',)"
+        self.assertTrue(u'CODE1' in self.app['applicants'].keys())
 
 def test_suite():
