mirror of https://github.com/langgenius/dify.git
test: migrate mcp tools manage service tests to testcontainers
This commit is contained in:
parent
f5cc1c8b75
commit
14bea8ed1b
|
|
@ -1391,3 +1391,52 @@ class TestMCPToolManageService:
|
|||
timeout=mcp_provider.timeout,
|
||||
sse_read_timeout=mcp_provider.sse_read_timeout,
|
||||
)
|
||||
|
||||
|
||||
def test_prepare_icon_returns_json_for_emoji(self):
|
||||
"""Emoji icon type should be serialized to JSON string."""
|
||||
import json
|
||||
|
||||
icon = {"type": "emoji", "emoji": "🔧"}
|
||||
result = MCPToolManageService._prepare_icon(icon)
|
||||
assert result == json.dumps(icon)
|
||||
|
||||
def test_prepare_icon_returns_raw_for_non_emoji(self):
|
||||
"""Non-emoji icon should be returned as-is."""
|
||||
icon = "https://example.com/icon.png"
|
||||
result = MCPToolManageService._prepare_icon(icon)
|
||||
assert result == icon
|
||||
|
||||
def test_list_providers_empty(
|
||||
self, db_session_with_containers: Session, mock_external_service_dependencies
|
||||
):
|
||||
"""Listing providers when none exist should return empty list."""
|
||||
account, tenant = self._create_test_account_and_tenant(
|
||||
db_session_with_containers, mock_external_service_dependencies
|
||||
)
|
||||
|
||||
result = MCPToolManageService.get_mcp_tools(account.id, tenant.id)
|
||||
assert result == []
|
||||
|
||||
def test_update_provider_name_conflict_raises_error(
|
||||
self, db_session_with_containers: Session, mock_external_service_dependencies
|
||||
):
|
||||
"""Updating a provider name to conflict with another should raise ValueError."""
|
||||
account, tenant = self._create_test_account_and_tenant(
|
||||
db_session_with_containers, mock_external_service_dependencies
|
||||
)
|
||||
|
||||
provider1 = self._create_test_mcp_provider(
|
||||
db_session_with_containers, tenant.id, account.id, name="Provider Alpha"
|
||||
)
|
||||
provider2 = self._create_test_mcp_provider(
|
||||
db_session_with_containers, tenant.id, account.id, name="Provider Beta"
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="already exists"):
|
||||
MCPToolManageService.update_mcp_tool(
|
||||
user_id=account.id,
|
||||
tenant_id=tenant.id,
|
||||
provider_id=provider2.id,
|
||||
name="Provider Alpha",
|
||||
)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue