Changeset 7508 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 25 Jan 2012, 12:42:24 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_batching.py
r7266 r7508 50 50 os.path.join(os.path.dirname(__file__), 'sample_applicant_data.csv'), 51 51 'rb').read() 52 FAULTY_APPLICANT_SAMPLE_DATA = open( 53 os.path.join(os.path.dirname(__file__), 54 'sample_faulty_applicant_data.csv'), 'rb').read() 55 52 56 53 57 APPLICANT_HEADER_FIELDS = APPLICANT_SAMPLE_DATA.split( … … 55 59 56 60 APPLICANT_SAMPLE_DATA_UPDATE = open( 57 os.path.join(os.path.dirname(__file__), 'sample_applicant_data_update.csv'),58 'rb').read()61 os.path.join(os.path.dirname(__file__), 62 'sample_applicant_data_update.csv'), 'rb').read() 59 63 60 64 APPLICANT_HEADER_FIELDS_UPDATE = APPLICANT_SAMPLE_DATA_UPDATE.split( … … 187 191 self.workdir = tempfile.mkdtemp() 188 192 self.csv_file = os.path.join(self.workdir, 'sample_applicant_data.csv') 193 self.csv_file_faulty = os.path.join(self.workdir, 194 'faulty_applicant_data.csv') 189 195 self.csv_file_update = os.path.join( 190 196 self.workdir, 'sample_applicant_data_update.csv') 191 197 open(self.csv_file, 'wb').write(APPLICANT_SAMPLE_DATA) 198 open(self.csv_file_faulty, 'wb').write(FAULTY_APPLICANT_SAMPLE_DATA) 192 199 open(self.csv_file_update, 'wb').write(APPLICANT_SAMPLE_DATA_UPDATE) 193 200 … … 238 245 shutil.rmtree(os.path.dirname(fin_file)) 239 246 247 def test_import_faulty(self): 248 # we cannot import data with faulty dates. A date is faulty 249 # when in format xx/yy/zzzz as we cannot say whether it is 250 # meant as dd/mm/yyyy or mm/dd/yyyy. We therefore require yyyy-mm-dd 251 num, num_warns, fin_file, fail_file = self.importer.doImport( 252 self.csv_file_faulty, APPLICANT_HEADER_FIELDS) 253 if fail_file is not None: 254 fail_contents = open(fail_file, 'rb').read() 255 shutil.rmtree(os.path.dirname(fail_file)) 256 else: 257 shutil.rmtree(os.path.dirname(fin_file)) 258 self.assertEqual(num_warns,1) 259 self.assertTrue( 260 'date_of_birth: Invalid datetime data' in fail_contents) 261 self.assertEqual(len(self.app['applicants']['dp2011'].keys()), 1) 262 return 263 240 264 def test_import_update(self): 241 265 num, num_warns, fin_file, fail_file = self.importer.doImport(
Note: See TracChangeset for help on using the changeset viewer.