<!-- CURSOR_SUMMARY --> > [!NOTE] > **Medium Risk** > Touches multiple toolkits’ runtime entrypoints and context/error/auth plumbing, so breakage risk is mainly around invocation/packaging and tool execution wiring rather than business logic. > > **Overview** > Migrates the BrightData, ClickHouse, LinkedIn, Math, MongoDB, Postgres, and Zendesk OSS toolkits from `arcade-tdk` to `arcade-mcp-server` APIs by updating tool decorators, `Context` types, auth classes, and exception imports. > > Adds per-toolkit `__main__.py` files that construct an `MCPApp`, register module tools, and run via configurable transport/host/port; corresponding `pyproject.toml` updates bump versions, drop `arcade-tdk`/`arcade-serve` deps, and add `project.scripts` console entrypoints. > > Updates tests and eval suites to use `arcade_mcp_server.Context` (mocked) and switches eval `ToolCatalog` imports to `arcade_core`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9b3e31acb4b35e1d72efd47e2d279c5b19e3ecb0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from unittest.mock import AsyncMock, MagicMock
|
|
|
|
import pytest
|
|
from arcade_mcp_server.exceptions import ToolExecutionError
|
|
|
|
from arcade_linkedin.tools.share import create_text_post
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_text_post_success(tool_context, mock_httpx_client):
|
|
"""Test successful creation of a LinkedIn text post."""
|
|
# Mock response for a successful post creation
|
|
mock_response = MagicMock()
|
|
mock_response.status_code = 201
|
|
mock_response.json.return_value = {"id": "1234567890"}
|
|
# Ensure the mock is awaited properly
|
|
mock_httpx_client.request = AsyncMock(return_value=mock_response)
|
|
|
|
post_text = "Hello, LinkedIn!"
|
|
result = await create_text_post(tool_context, post_text)
|
|
|
|
expected_url = "https://www.linkedin.com/feed/update/1234567890/"
|
|
assert result == expected_url
|
|
mock_httpx_client.request.assert_called_once()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_text_post_no_user_id(tool_context):
|
|
"""Test error when user ID is not found in the context."""
|
|
# Simulate missing user ID in the context
|
|
tool_context.authorization.user_info = {}
|
|
|
|
post_text = "Hello, LinkedIn!"
|
|
with pytest.raises(ToolExecutionError, match="User ID not found"):
|
|
await create_text_post(tool_context, post_text)
|