Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
test: use concrete archive adapter boundaries (#43373)
Asuka Minatofd99ce64c995
diff --git a/api/tests/unit_tests/services/retention/workflow_run/test_archive_download_adapters.py b/api/tests/unit_tests/services/retention/workflow_run/test_archive_download_adapters.pyindex 6d69520eedb..cca74d411c3 100644--- a/api/tests/unit_tests/services/retention/workflow_run/test_archive_download_adapters.py+++ b/api/tests/unit_tests/services/retention/workflow_run/test_archive_download_adapters.py@@ -1,9 +1,10 @@import sys-from types import ModuleType, SimpleNamespace-from unittest.mock import MagicMock+from collections.abc import Callable+from types import ModuleTypeimport pytest+from libs.archive_storage import ArchiveStoragefrom services.retention.workflow_run import archive_download_adaptersfrom services.retention.workflow_run.archive_download_adapters import (dispatch_workflow_run_archive_download_task,@@ -28,44 +29,59 @@ def _task(*, celery_task_id: str | None = "celery-task-1") -> WorkflowRunArchive).model_copy(update={"celery_task_id": celery_task_id})-def _patch_archive_download_task(monkeypatch: pytest.MonkeyPatch, *, apply_async: MagicMock) -> None:+def _patch_archive_download_task(+ monkeypatch: pytest.MonkeyPatch,+ *,+ apply_async: Callable[..., None],+) -> None:task_module = ModuleType("tasks.workflow_run_archive_download_tasks")- task_module.__dict__["prepare_workflow_run_archive_download_task"] = SimpleNamespace(apply_async=apply_async)+ celery_task = ModuleType("prepare_workflow_run_archive_download_task")+ celery_task.__dict__["apply_async"] = apply_async+ task_module.__dict__["prepare_workflow_run_archive_download_task"] = celery_taskmonkeypatch.setitem(sys.modules, task_module.__name__, task_module)def test_dispatch_workflow_run_archive_download_task_enqueues_claimed_task(monkeypatch: pytest.MonkeyPatch,) -> None:- apply_async = MagicMock()+ calls: list[tuple[tuple[str, str], str]] = []++ def apply_async(*, args: tuple[str, str], task_id: str) -> None:+ calls.append((args, task_id))+_patch_archive_download_task(monkeypatch, apply_async=apply_async)result = dispatch_workflow_run_archive_download_task(_task())assert result is None- apply_async.assert_called_once_with(- args=("tenant-1", "download-1"),- task_id="celery-task-1",- )+ assert calls == [(("tenant-1", "download-1"), "celery-task-1")]def test_dispatch_workflow_run_archive_download_task_requires_claim_id(monkeypatch: pytest.MonkeyPatch,) -> None:- apply_async = MagicMock()+ calls: list[tuple[tuple[str, str], str]] = []++ def apply_async(*, args: tuple[str, str], task_id: str) -> None:+ calls.append((args, task_id))+_patch_archive_download_task(monkeypatch, apply_async=apply_async)with pytest.raises(ValueError, match="celery_task_id is required before dispatch"):dispatch_workflow_run_archive_download_task(_task(celery_task_id=None))- apply_async.assert_not_called()+ assert calls == []def test_dispatch_workflow_run_archive_download_task_propagates_enqueue_error(monkeypatch: pytest.MonkeyPatch,) -> None:failure = RuntimeError("broker unavailable")- apply_async = MagicMock(side_effect=failure)++ def apply_async(*, args: tuple[str, str], task_id: str) -> None:+ del args, task_id+ raise failure+_patch_archive_download_task(monkeypatch, apply_async=apply_async)with pytest.raises(RuntimeError) as raised:@@ -77,12 +93,28 @@ def test_dispatch_workflow_run_archive_download_task_propagates_enqueue_error(def test_sign_workflow_run_archive_download_url_resolves_export_storage_lazily(monkeypatch: pytest.MonkeyPatch,) -> None:- storage = MagicMock()- storage.generate_presigned_url.return_value = "https://download.example/archive.zip"- get_export_storage = MagicMock(return_value=storage)+ storage = object.__new__(ArchiveStorage)+ get_export_storage_calls: list[None] = []+ generate_presigned_url_calls: list[tuple[str, int, str | None, str | None]] = []++ def generate_presigned_url(+ key: str,+ expires_in: int = 3600,+ *,+ filename: str | None = None,+ content_type: str | None = None,+ ) -> str:+ generate_presigned_url_calls.append((key, expires_in, filename, content_type))+ return "https://download.example/archive.zip"++ def get_export_storage() -> ArchiveStorage:+ get_export_storage_calls.append(None)+ return storage++ monkeypatch.setattr(storage, "generate_presigned_url", generate_presigned_url)monkeypatch.setattr(archive_download_adapters, "get_export_storage", get_export_storage)- assert get_export_storage.call_count == 0+ assert get_export_storage_calls == []result = sign_workflow_run_archive_download_url("downloads/archive.zip",@@ -91,10 +123,7 @@ def test_sign_workflow_run_archive_download_url_resolves_export_storage_lazily()assert result == "https://download.example/archive.zip"- get_export_storage.assert_called_once_with()- storage.generate_presigned_url.assert_called_once_with(- "downloads/archive.zip",- expires_in=900,- filename="workflow-run-logs-2025-03.zip",- content_type="application/zip",- )+ assert get_export_storage_calls == [None]+ assert generate_presigned_url_calls == [+ ("downloads/archive.zip", 900, "workflow-run-logs-2025-03.zip", "application/zip")+ ]