From 52f44aecaa97f0a341521a9c81d3e8cbe47d4a66 Mon Sep 17 00:00:00 2001 From: Greg Kostin Date: Tue, 4 Mar 2025 17:25:34 -0500 Subject: [PATCH] cleanup --- dor/providers/translocator.py | 4 ++-- dor/service_layer/handlers/catalog_revision.py | 2 +- features/steps/test_store_resource.py | 1 - features/steps/test_update_resource.py | 2 +- tests/test_translocator.py | 11 ++++------- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/dor/providers/translocator.py b/dor/providers/translocator.py index 2b1a014..6b7f4e6 100644 --- a/dor/providers/translocator.py +++ b/dor/providers/translocator.py @@ -44,6 +44,7 @@ def get_bundle(self, entries: list[Path]) -> Bundle: entries=entries ) + class FakeTranslocator: def create_workspace_for_package(self, package_identifier: str) -> FakeWorkspace: @@ -52,7 +53,7 @@ def create_workspace_for_package(self, package_identifier: str) -> FakeWorkspace class Translocator(): - def __init__(self, inbox_path: Path, workspaces_path: Path, minter: Callable[[],str], file_provider: FileProvider) -> None: + def __init__(self, inbox_path: Path, workspaces_path: Path, minter: Callable[[], str], file_provider: FileProvider) -> None: self.inbox_path = inbox_path self.workspaces_path = workspaces_path self.minter = minter @@ -65,4 +66,3 @@ def create_workspace_for_package(self, package_identifier: str) -> Workspace: self.inbox_path / package_identifier, workspace_path ) return Workspace(str(workspace_path)) - diff --git a/dor/service_layer/handlers/catalog_revision.py b/dor/service_layer/handlers/catalog_revision.py index d4d83ad..eeade51 100644 --- a/dor/service_layer/handlers/catalog_revision.py +++ b/dor/service_layer/handlers/catalog_revision.py @@ -35,6 +35,6 @@ def catalog_revision(event: PackageStored, uow: AbstractUnitOfWork) -> None: identifier=event.identifier, workspace_identifier=event.workspace_identifier, tracking_identifier=event.tracking_identifier, - package_identifier=event.package_identifier, + package_identifier=event.package_identifier )) \ No newline at end of file diff --git a/features/steps/test_store_resource.py b/features/steps/test_store_resource.py index 560c0f0..c76e40b 100644 --- a/features/steps/test_store_resource.py +++ b/features/steps/test_store_resource.py @@ -37,7 +37,6 @@ from gateway.ocfl_repository_gateway import OcflRepositoryGateway from utils.minter import minter - @dataclass class PathData: scratch: Path diff --git a/features/steps/test_update_resource.py b/features/steps/test_update_resource.py index e5b1d9f..a514ce2 100644 --- a/features/steps/test_update_resource.py +++ b/features/steps/test_update_resource.py @@ -184,7 +184,7 @@ def test_updating_only_metadata_of_a_resource_for_immediate_release(): def _( path_data: PathData, unit_of_work: AbstractUnitOfWork, message_bus: MemoryMessageBus ): - """a package containing all the scanned pages, OCR, and metadata.""" + """a package containing updated resource metadata""" file_provider = FilesystemFileProvider() file_provider.delete_dir_and_contents(path=path_data.scratch) file_provider.create_directory(path_data.scratch) diff --git a/tests/test_translocator.py b/tests/test_translocator.py index ec09141..b4db45d 100644 --- a/tests/test_translocator.py +++ b/tests/test_translocator.py @@ -5,8 +5,6 @@ from dor.providers.file_system_file_provider import FilesystemFileProvider from dor.providers.translocator import Translocator -from utils.minter import minter - @pytest.fixture def workspaces_path() -> Path: return Path("tests/test_workspaces") @@ -17,22 +15,21 @@ def inbox_path() -> Path: def test_create_translocator(inbox_path: Path, workspaces_path: Path) -> None: Translocator( - inbox_path=inbox_path, workspaces_path=workspaces_path, minter=minter, file_provider=FilesystemFileProvider() + inbox_path=inbox_path, workspaces_path=workspaces_path, minter=lambda: "some_id", file_provider=FilesystemFileProvider() ) def test_translocator_can_create_workspace(inbox_path: Path, workspaces_path: Path) -> None: - mint = 'a2574fa4-f169-48b5-a5df-6287fe5ef1aa' file_provider = FilesystemFileProvider() file_provider.delete_dir_and_contents( - Path(workspaces_path / mint) + Path(workspaces_path / "some_id") ) translocator = Translocator( inbox_path=inbox_path, workspaces_path=workspaces_path, - minter=lambda : mint, + minter=lambda : "some_id", file_provider=file_provider ) workspace = translocator.create_workspace_for_package("xyzzy-0001-v1") - assert workspace.identifier == str(workspaces_path / mint) + assert workspace.identifier == str(workspaces_path / "some_id") assert Path(workspace.identifier).exists()