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 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 set_up(source_file_path, target_file_type, mode):
    target_file_path = get_target_file_path(target_file_type, source_file_path)

    if not CSVOperations.check_file_exists(source_file_path):
        print(source_file_path)
        raise MappingFileNotFound(
            'Mapping File Not Found at' + source_file_path, source_file_path)

    if CSVOperations.check_file_exists(
            target_file_path) and mode != Mode.APPEND:
        CSVOperations.delete_file(target_file_path)

    if not CSVOperations.check_file_exists(target_file_path):
        CSVOperations.create_file(target_file_path, target_file_type)
 def test_file_delete(self):
     csvops.create_file(self.test_file_path, TargetCSVType.INDIVIDUAL)
     csvops.delete_file(self.test_file_path)
     self.assertFalse(csvops.check_file_exists(self.test_file_path))
 def test_created_file_has_no_additional_headers(self):
     csvops.create_file(self.test_file_path, TargetCSVType.INDIVIDUAL)
     self.assertEqual(len(TargetCSVType.INDIVIDUAL.columns),
                      csvops.get_header_count(self.test_file_path))
 def __create_family_file(self):
     target_type = TargetCSVType.FAMILY
     csvops.create_file(self.test_file_path, target_type)
 def __create_individual_file(self):
     target_type = TargetCSVType.INDIVIDUAL
     csvops.create_file(self.test_file_path, target_type)