Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix: replace SimpleNamespace with MagicMock(spec=App) in _app_stub (#34636) (#35897)

EvanYao936a09c70494
diff --git a/api/tests/test_containers_integration_tests/services/test_app_dsl_service.py b/api/tests/test_containers_integration_tests/services/test_app_dsl_service.py
index 6b844615b5c..7c5d2390bac 100644
--- a/api/tests/test_containers_integration_tests/services/test_app_dsl_service.py
+++ b/api/tests/test_containers_integration_tests/services/test_app_dsl_service.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import base64
import json
from types import SimpleNamespace
-from typing import Any, cast
+from typing import Any
from unittest.mock import MagicMock, patch
from uuid import uuid4
@@ -71,6 +71,7 @@ def _pending_yaml_content(version: str = "99.0.0") -> bytes:
def _app_stub(**overrides: Any) -> App:
+ """Create a stub App object for testing without hitting the database."""
defaults = {
"id": str(uuid4()),
"tenant_id": _DEFAULT_TENANT_ID,
@@ -83,7 +84,10 @@ def _app_stub(**overrides: Any) -> App:
"use_icon_as_answer_icon": False,
"app_model_config": None,
}
- return cast(App, SimpleNamespace(**(defaults | overrides)))
+ app = MagicMock(spec=App)
+ for key, value in (defaults | overrides).items():
+ object.__setattr__(app, key, value)
+ return app
class TestAppDslService: