def setup(self):
        self.packages = []

        try:
            package_set = packages.create_package("Hathi", self.path)
            for package in package_set:
                self.packages.append(package)
        except packages.PackageError as e:
            self.valid = False
            new_error = error_message.ValidationError(e, group=self.path)
            new_error.source = self.path
            self.errors.append(new_error)

        # Add the tasks that need to be validated
        for hathi_package in self.packages:
            task_name = hathi_package.directories["preservation"].split(os.path.sep)[-1]

            my_task = tasks.Task(description="Validating {} in {}".format(task_name, hathi_package.root))

            # Package Structure Completeness:
            package_structure_test = validation_processors.PackageStructureComplete()
            package_structure_test.setup()
            package_structure_test.set_input(hathi_package.root)
            my_task.add_process(package_structure_test)

            # Package component Completeness:
            package_component_test = validation_processors.PackageComponentComplete()
            package_component_test.setup()
            package_component_test.set_input(hathi_package)
            my_task.add_process(package_component_test)

            # Preservation Folder
            preservation_folder_completeness_test = validation_processors.PackagePreservationComplete()
            preservation_folder_completeness_test.setup()
            preservation_folder_completeness_test.set_input(hathi_package.directories["preservation"])
            my_task.add_process(preservation_folder_completeness_test)

            # Access folder
            access_folder_completeness_test = validation_processors.PackageAccessComplete()
            access_folder_completeness_test.setup()
            access_folder_completeness_test.set_input(hathi_package.directories['access'])
            my_task.add_process(access_folder_completeness_test)

            # Preservation file name
            for file in os.scandir(hathi_package.directories["preservation"]):
                preservation_file_naming_test = validation_processors.PreservationFileNaming()
                preservation_file_naming_test.setup()
                preservation_file_naming_test.set_input(file.path)
                my_task.add_process(preservation_file_naming_test)

            # Access file name
            for file in os.scandir(hathi_package.directories["access"]):
                access_file_naming_test = validation_processors.AccessFileNaming()
                access_file_naming_test.setup()
                access_file_naming_test.set_input(file.path)
                my_task.add_process(access_file_naming_test)

            self.manager.push(my_task)
Exemplo n.º 2
0
 def get_package_type(self) -> abs_package.AbsPackage:
     x = packages.create_package("Hathi")
     return x
def test_load_hathi_package_path_after(hathi_sample_package):
    new_pkg = packages.create_package("Hathi")
    new_pkg.root_path = str(hathi_sample_package)
    # new_pkg = packages.create_package("Hathi", root_path=str(hathi_sample_package))
    assert len(new_pkg) == 7
def test_hathi_package_iter_path_after(hathi_sample_package):
    new_pkg = packages.create_package("Hathi")
    new_pkg.root_path = str(hathi_sample_package)
    for item in new_pkg:
        assert isinstance(item, packages.abs_package.PackageItem)
def test_get_hathi_package_path_after(hathi_sample_package):
    new_pkg = packages.create_package("Hathi")
    new_pkg.root_path = str(hathi_sample_package)
    assert isinstance(new_pkg, packages.Hathi)
Exemplo n.º 6
0
def test_hathi_submit_package_get_package_files(hathi_sample_package):
    new_pkg = packages.create_package("HathiSubmit")
    new_pkg.root_path = str(hathi_sample_package)
    for package in new_pkg:
        assert isinstance(package, packages.abs_package.PackageItem)
Exemplo n.º 7
0
def test_hathi_submit_package_iter(hathi_sample_package):
    new_pkg = packages.create_package("HathiSubmit",
                                      root_path=str(hathi_sample_package))
    for package in new_pkg:
        assert isinstance(package, packages.abs_package.PackageItem)
        assert package.root != str(hathi_sample_package)
Exemplo n.º 8
0
def test_load_hathi_submit_package(hathi_sample_package):
    new_pkg = packages.create_package("HathiSubmit",
                                      root_path=str(hathi_sample_package))
    assert len(new_pkg) == 12
Exemplo n.º 9
0
def test_get_hathi_submit_package(hathi_sample_package):
    new_pkg = packages.create_package("HathiSubmit",
                                      root_path=str(hathi_sample_package))
    assert isinstance(new_pkg, packages.HathiSubmit)