def test_set_up_deletes_in_not_append_mode(self): # Create individual type CSV (called Family.csv) target_file_path = Mapper.get_target_file_path(TargetCSVType.FAMILY, self.test_file_path) csvops.create_file(target_file_path, TargetCSVType.INDIVIDUAL) Mapper.set_up(target_file_path, TargetCSVType.FAMILY, Mode.Mode.CREATE) # Ensure that the old individual CSV was deleted and replaced with a file with Family CSV headers self.assertTrue( csvops.check_headers_match(target_file_path, TargetCSVType.FAMILY))
def run(): settings = get_settings() for file_type, source_file_path in settings.items(): source_type = get_source_csv_type(file_type) for target_type in source_type.target_types: if isinstance(source_file_path, list): for path in source_file_path: Mapper.run(path, target_type, source_type) else: Mapper.run(source_file_path, target_type, source_type)
def test_set_up_does_not_delete_in_append_mode(self): # Create individual type CSV (called Family.csv) target_file_path = Mapper.get_target_file_path(TargetCSVType.FAMILY, self.test_file_path) csvops.create_file(target_file_path, TargetCSVType.INDIVIDUAL) # Should not delete the file, if it does it won't be an INDIVIDUAL type file Mapper.set_up(target_file_path, TargetCSVType.FAMILY, Mode.Mode.APPEND) # Ensure that the old individual CSV was not deleted self.assertTrue( csvops.check_headers_match(target_file_path, TargetCSVType.INDIVIDUAL))
def tearDown(self): try: os.remove(self.test_file_path) except OSError: pass try: os.remove( Mapper.get_target_file_path(TargetCSVType.FAMILY, self.test_file_path)) except OSError: pass try: os.remove( Mapper.get_target_file_path(TargetCSVType.INDIVIDUAL, self.test_file_path)) except OSError: pass
def test_set_up_no_source_file_path_exception(self): with self.assertRaises(MappingFileNotFound.MappingFileNotFound): Mapper.set_up(self.test_file_path, TargetCSVType.INDIVIDUAL, Mode.Mode.APPEND)
def test_get_family_csv_file_path(self): self.assertEqual( Mapper.get_target_file_path(TargetCSVType.FAMILY, self.test_file_path), THIS_DIR + '\\' + TargetCSVType.FAMILY.name.lower() + '.csv')
def test_get_individual_csv_file_path(self): self.assertEqual( Mapper.get_target_file_path(TargetCSVType.INDIVIDUAL, self.test_file_path), THIS_DIR + '\\' + TargetCSVType.INDIVIDUAL.name.lower() + '.csv')