Changeset 7933 for main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests
- Timestamp:
- 21 Mar 2012, 13:42:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py
r7912 r7933 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 """Unit tests for applicants-related data importers.18 """Unit tests for applicants-related data processors. 19 19 """ 20 20 import datetime … … 29 29 from waeup.kofa.app import University 30 30 from waeup.kofa.applicants.batching import ( 31 ApplicantsContainer Importer, ApplicantImporter)31 ApplicantsContainerProcessor, ApplicantProcessor) 32 32 from waeup.kofa.applicants.container import ApplicantsContainer 33 33 from waeup.kofa.applicants.applicant import Applicant … … 66 66 '\n')[0].split(',') 67 67 68 class ApplicantsContainer ImporterTest(FunctionalTestCase):68 class ApplicantsContainerProcessorTest(FunctionalTestCase): 69 69 70 70 layer = FunctionalLayer 71 71 72 72 def setUp(self): 73 super(ApplicantsContainer ImporterTest, self).setUp()73 super(ApplicantsContainerProcessorTest, self).setUp() 74 74 75 75 # Setup a sample site for each test … … 85 85 self.app['applicants']['dp2011'] = self.container 86 86 87 self. importer = ApplicantsContainerImporter()87 self.processor = ApplicantsContainerProcessor() 88 88 self.workdir = tempfile.mkdtemp() 89 89 self.csv_file = os.path.join(self.workdir, 'sampledata.csv') … … 93 93 94 94 def tearDown(self): 95 super(ApplicantsContainer ImporterTest, self).tearDown()95 super(ApplicantsContainerProcessorTest, self).tearDown() 96 96 shutil.rmtree(self.workdir) 97 97 shutil.rmtree(self.dc_root) … … 101 101 def test_interface(self): 102 102 # Make sure we fulfill the interface contracts. 103 assert verifyObject(IBatchProcessor, self. importer) is True103 assert verifyObject(IBatchProcessor, self.processor) is True 104 104 assert verifyClass( 105 IBatchProcessor, ApplicantsContainer Importer) is True105 IBatchProcessor, ApplicantsContainerProcessor) is True 106 106 107 107 def test_parentsExist(self): 108 assert self. importer.parentsExist(None, dict()) is False109 assert self. importer.parentsExist(None, self.app) is True108 assert self.processor.parentsExist(None, dict()) is False 109 assert self.processor.parentsExist(None, self.app) is True 110 110 111 111 def test_entryExists(self): 112 assert self. importer.entryExists(112 assert self.processor.entryExists( 113 113 dict(code='REG_NONE'), self.app) is False 114 assert self. importer.entryExists(114 assert self.processor.entryExists( 115 115 dict(code='dp2011'), self.app) is True 116 116 117 117 def test_getParent(self): 118 parent = self. importer.getParent(None, self.app)118 parent = self.processor.getParent(None, self.app) 119 119 assert parent is self.app['applicants'] 120 120 121 121 def test_getEntry(self): 122 assert self. importer.getEntry(122 assert self.processor.getEntry( 123 123 dict(code='REG_NONE'), self.app) is None 124 assert self. importer.getEntry(124 assert self.processor.getEntry( 125 125 dict(code='dp2011'), self.app) is self.container 126 126 127 127 def test_addEntry(self): 128 self. importer.addEntry(128 self.processor.addEntry( 129 129 'New application', dict(code='dp2012'), self.app) 130 130 assert self.app['applicants']['dp2012'] == 'New application' 131 131 132 132 def test_delEntry(self): 133 self. importer.delEntry(dict(code='dp2011'), self.app)133 self.processor.delEntry(dict(code='dp2011'), self.app) 134 134 assert 'dp2011' not in self.app['applicants'].keys() 135 135 … … 137 137 # Do a real import 138 138 # 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( 140 140 self.csv_file, APPS_CONTAINER_HEADER_FIELDS) 141 141 avail_containers = [x for x in self.app['applicants'].keys()] … … 219 219 return 220 220 221 class Applicant ImporterTest(ApplicantImportExportSetup):221 class ApplicantProcessorTest(ApplicantImportExportSetup): 222 222 223 223 layer = FunctionalLayer 224 224 225 225 def setUp(self): 226 super(Applicant ImporterTest, self).setUp()227 self. importer = ApplicantImporter()226 super(ApplicantProcessorTest, self).setUp() 227 self.processor = ApplicantProcessor() 228 228 self.csv_file = os.path.join(self.workdir, 'sample_applicant_data.csv') 229 229 self.csv_file_faulty = os.path.join(self.workdir, … … 237 237 def test_interface(self): 238 238 # Make sure we fulfill the interface contracts. 239 assert verifyObject(IBatchProcessor, self. importer) is True239 assert verifyObject(IBatchProcessor, self.processor) is True 240 240 assert verifyClass( 241 IBatchProcessor, Applicant Importer) is True241 IBatchProcessor, ApplicantProcessor) is True 242 242 243 243 def test_entryExists(self): 244 assert self. importer.entryExists(244 assert self.processor.entryExists( 245 245 dict(container_code='dp2011', application_number='999'), 246 246 self.app) is False 247 247 248 248 def test_getEntry(self): 249 applicant = self. importer.getEntry(249 applicant = self.processor.getEntry( 250 250 dict(container_code='dp2011', 251 251 application_number=self.application_number), self.app) … … 254 254 def test_addEntry(self): 255 255 new_applicant = Applicant() 256 self. importer.addEntry(256 self.processor.addEntry( 257 257 new_applicant, dict(container_code='dp2011'), self.app) 258 258 assert len(self.app['applicants']['dp2011'].keys()) == 2 … … 261 261 assert self.application_number in self.app[ 262 262 'applicants']['dp2011'].keys() 263 self. importer.delEntry(263 self.processor.delEntry( 264 264 dict(container_code='dp2011', 265 265 application_number=self.application_number), self.app) … … 268 268 269 269 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( 271 271 self.csv_file, APPLICANT_HEADER_FIELDS) 272 272 self.assertEqual(num_warns,0) … … 285 285 # when in format xx/yy/zzzz as we cannot say whether it is 286 286 # 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( 288 288 self.csv_file_faulty, APPLICANT_HEADER_FIELDS) 289 289 if fail_file is not None: … … 300 300 301 301 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( 303 303 self.csv_file, APPLICANT_HEADER_FIELDS) 304 304 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( 306 306 self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'update') 307 307 self.assertEqual(num_warns,0) … … 309 309 310 310 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( 312 312 self.csv_file, APPLICANT_HEADER_FIELDS) 313 313 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( 315 315 self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'remove') 316 316 self.assertEqual(num_warns,0)
Note: See TracChangeset for help on using the changeset viewer.