test: remove duplicate integration-only coverage

This commit is contained in:
Asuka Minato 2026-08-13 13:56:05 +09:00
parent 4bb217db65
commit ac4578d290
3 changed files with 0 additions and 203 deletions

View File

@ -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)

View File

@ -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"
@pytest.fixture
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()

View File

@ -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