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.

test: remove duplicate integration-only coverage (#40711)

Asuka Minato8b9f3016e672
diff --git a/api/tests/integration_tests/controllers/console/app/test_description_validation.py b/api/tests/integration_tests/controllers/console/app/test_description_validation.py
deleted file mode 100644
index f36c596eb84..00000000000
--- a/api/tests/integration_tests/controllers/console/app/test_description_validation.py
+++ /dev/null
@@ -1,127 +0,0 @@
-"""
-Unit tests for App description validation functions.
-
-This test module validates the 400-character limit enforcement
-for App descriptions across all creation and editing endpoints.
-"""
-
-import sys
-
-import pytest
-
-
-class TestAppDescriptionValidationUnit:
- """Unit tests for description validation function"""
-
- def test_validate_description_length_function(self):
- """Test the validate_description_length function directly"""
- from libs.validators import validate_description_length
-
- # Test valid descriptions
- assert validate_description_length("") == ""
- assert validate_description_length("x" * 400) == "x" * 400
- assert validate_description_length(None) is None
-
- # Test invalid descriptions
- with pytest.raises(ValueError) as exc_info:
- validate_description_length("x" * 401)
- assert "Description cannot exceed 400 characters." in str(exc_info.value)
-
- with pytest.raises(ValueError) as exc_info:
- validate_description_length("x" * 500)
- assert "Description cannot exceed 400 characters." in str(exc_info.value)
-
- with pytest.raises(ValueError) as exc_info:
- validate_description_length("x" * 1000)
- assert "Description cannot exceed 400 characters." in str(exc_info.value)
-
- def test_boundary_values(self):
- """Test boundary values for description validation"""
- from libs.validators import validate_description_length
-
- # Test exact boundary
- exactly_400 = "x" * 400
- assert validate_description_length(exactly_400) == exactly_400
-
- # Test just over boundary
- just_over_400 = "x" * 401
- with pytest.raises(ValueError):
- validate_description_length(just_over_400)
-
- # Test just under boundary
- just_under_400 = "x" * 399
- assert validate_description_length(just_under_400) == just_under_400
-
- def test_edge_cases(self):
- """Test edge cases for description validation"""
- from libs.validators import validate_description_length
-
- # Test None input
- assert validate_description_length(None) is None
-
- # Test empty string
- assert validate_description_length("") == ""
-
- # Test single character
- assert validate_description_length("a") == "a"
-
- # Test unicode characters
- unicode_desc = "测试" * 200 # 400 characters in Chinese
- assert validate_description_length(unicode_desc) == unicode_desc
-
- # Test unicode over limit
- unicode_over = "测试" * 201 # 402 characters
- with pytest.raises(ValueError):
- validate_description_length(unicode_over)
-
- def test_whitespace_handling(self):
- """Test how validation handles whitespace"""
- from libs.validators import validate_description_length
-
- # Test description with spaces
- spaces_400 = " " * 400
- assert validate_description_length(spaces_400) == spaces_400
-
- # Test description with spaces over limit
- spaces_401 = " " * 401
- with pytest.raises(ValueError):
- validate_description_length(spaces_401)
-
- # Test mixed content
- mixed_400 = "a" * 200 + " " * 200
- assert validate_description_length(mixed_400) == mixed_400
-
- # Test mixed over limit
- mixed_401 = "a" * 200 + " " * 201
- with pytest.raises(ValueError):
- validate_description_length(mixed_401)
-
-
-if __name__ == "__main__":
- # Run tests directly
- import traceback
-
- test_instance = TestAppDescriptionValidationUnit()
- test_methods = [method for method in dir(test_instance) if method.startswith("test_")]
-
- passed = 0
- failed = 0
-
- for test_method in test_methods:
- try:
- print(f"Running {test_method}...")
- getattr(test_instance, test_method)()
- print(f"✅ {test_method} PASSED")
- passed += 1
- except Exception as e:
- print(f"❌ {test_method} FAILED: {str(e)}")
- traceback.print_exc()
- failed += 1
-
- print(f"\n📊 Test Results: {passed} passed, {failed} failed")
-
- if failed == 0:
- print("🎉 All tests passed!")
- else:
- print("💥 Some tests failed!")
- sys.exit(1)
diff --git a/api/tests/integration_tests/plugin/__mock/http.py b/api/tests/integration_tests/plugin/__mock/http.py
deleted file mode 100644
index b39e4a8e762..00000000000
--- a/api/tests/integration_tests/plugin/__mock/http.py
+++ /dev/null
@@ -1,67 +0,0 @@
-import os
-from typing import Literal
-
-import httpx
-import pytest
-
-from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse, PluginToolProviderEntity
-from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolProviderEntityWithPlugin, ToolProviderIdentity
-
-
-class MockedHttp:
- @classmethod
- def list_tools(cls) -> list[PluginToolProviderEntity]:
- return [
- PluginToolProviderEntity(
- provider="Yeuoly",
- plugin_unique_identifier="langgenius/yeuoly:0.0.1@mock",
- plugin_id="mock-plugin",
- declaration=ToolProviderEntityWithPlugin(
- identity=ToolProviderIdentity(
- author="Yeuoly",
- name="Yeuoly",
- description=I18nObject(en_US="Yeuoly"),
- icon="ssss.svg",
- label=I18nObject(en_US="Yeuoly"),
- )
- ),
- )
- ]
-
- @classmethod
- def requests_request(
- cls, method: Literal["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"], url: str, **kwargs
- ) -> httpx.Response:
- """
- Mocked httpx.request
- """
- request = httpx.Request(method, url)
- if url.endswith("/tools"):
- content = PluginDaemonBasicResponse[list[PluginToolProviderEntity]](
- code=0, message="success", data=cls.list_tools()
- ).model_dump_json()
- else:
- raise ValueError("")
-
- response = httpx.Response(status_code=200)
- response.request = request
- response._content = content.encode("utf-8")
- return response
-
-
-MOCK_SWITCH = os.getenv("MOCK_SWITCH", "false").lower() == "true"
-
-
-def setup_http_mock(request, monkeypatch: pytest.MonkeyPatch):
- if MOCK_SWITCH:
- monkeypatch.setattr(httpx, "request", MockedHttp.requests_request)
-
- def unpatch():
- monkeypatch.undo()
-
- yield
-
- if MOCK_SWITCH:
- unpatch()
diff --git a/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py b/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py
deleted file mode 100644
index 9a4450a454f..00000000000
--- a/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from core.plugin.impl.tool import PluginToolManager
-
-pytest_plugins = ("tests.integration_tests.plugin.__mock.http",)
-
-
-def test_fetch_all_plugin_tools(setup_http_mock):
- manager = PluginToolManager()
- tools = manager.fetch_tool_providers(tenant_id="test-tenant")
- assert len(tools) >= 1