### Overview Major restructuring from monolithic `arcade-ai` package to modular library architecture with standardized uv-based dependency management.  ### New Package Structure - **`arcade-tdk`** - Lightweight toolkit development kit (core decorators, auth) - **`arcade-core`** - Core execution engine and catalog functionality - **`arcade-serve`** - FastAPI/MCP server components - **`arcade-ai`** - Meta package that includes CLI functionality. Optionally include evals via the `evals` extra. Optionally include all packages via the `all` extra. ### Key Benefits - **Lighter Dependencies**: Toolkits now depend only on `arcade-tdk` (~2 deps) vs full `arcade-ai` (~30+ deps) - **Faster Builds**: uv provides 10-100x faster dependency resolution and installation - **Better Modularity**: Clear separation of concerns, consumers import only what they need - **Standard Tooling**: Eliminates custom poetry scripts, uses standard Python packaging ### Migration Impact - All 20 toolkits converted from poetry → uv with `arcade-tdk` dependencies plus `arcade-ai[evals]` and `arcade-serve` dev dependencies. When developing locally, devs should install toolkits via `make install-local`. - Modern Python 3.10+ type hints throughout - Standardized build system with hatchling backend - Enhanced Makefile with robust toolkit management commands - Removed `arcade dev` CLI command - Reduce the number of files created by `arcade new` and add an option to not generate a tests and evals folder. This foundation enables faster development cycles and cleaner dependency chains for the growing toolkit ecosystem. ### Todo After this PR is merged - [ ] Post-merge workflow(s) (release & publish containers, etc) - [ ] Release order plan. @EricGustin suggests releasing in the following order: 1. `arcade-core` version 0.1.0 2. `arcade-serve` version 0.1.0 and `arcade-tdk` version 0.1.0 3. `arcade-ai` version 2.0.0 4. Patch release for all toolkits (all changes in toolkits are internal refactors) - [ ] [Update docs](https://github.com/ArcadeAI/docs/pull/318) --------- Co-authored-by: Eric Gustin <eric@arcade.dev> Co-authored-by: Eric Gustin <34000337+EricGustin@users.noreply.github.com>
92 lines
3.1 KiB
Python
92 lines
3.1 KiB
Python
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from arcade_tdk.errors import RetryableToolError
|
|
from slack_sdk.errors import SlackApiError
|
|
|
|
from arcade_slack.tools.users import get_user_info_by_id, list_users
|
|
from arcade_slack.utils import extract_basic_user_info
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_slack_client(mocker):
|
|
mock_client = mocker.patch("arcade_slack.tools.users.AsyncWebClient", autospec=True)
|
|
return mock_client.return_value
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_user_info_by_id_success(mock_context, mock_slack_client):
|
|
# Mock the response from slackClient.users_info
|
|
mock_user = {
|
|
"id": "U12345",
|
|
"name": "testuser",
|
|
"real_name": "Test User",
|
|
"profile": {"email": "testuser@example.com"},
|
|
}
|
|
mock_slack_client.users_info.return_value = {"ok": True, "user": mock_user}
|
|
|
|
# Call the function
|
|
response = await get_user_info_by_id(mock_context, user_id="U12345")
|
|
|
|
# Verify that the correct Slack API method was called
|
|
mock_slack_client.users_info.assert_called_once_with(user="U12345")
|
|
|
|
# Verify the response
|
|
expected_response = extract_basic_user_info(mock_user)
|
|
assert response == expected_response
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@patch("arcade_slack.tools.users.list_users")
|
|
async def test_get_user_info_by_id_user_not_found(mock_list_users, mock_context, mock_slack_client):
|
|
error_response = {"ok": False, "error": "user_not_found"}
|
|
mock_slack_client.users_info.side_effect = SlackApiError(
|
|
message="User not found",
|
|
response=error_response,
|
|
)
|
|
|
|
existing_user = {"id": "U12345", "name": "testuser"}
|
|
mock_list_users.return_value = {"users": [existing_user]}
|
|
|
|
with pytest.raises(RetryableToolError) as e:
|
|
await get_user_info_by_id(mock_context, user_id="U99999")
|
|
|
|
assert existing_user["id"] in e.value.additional_prompt_content
|
|
assert existing_user["name"] in e.value.additional_prompt_content
|
|
|
|
mock_slack_client.users_info.assert_called_once_with(user="U99999")
|
|
mock_list_users.assert_called_once_with(mock_context)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_users_success(mock_context, mock_slack_client):
|
|
mock_slack_client.users_list.return_value = {"ok": True, "members": [{"id": "U12345"}]}
|
|
response = await list_users(mock_context)
|
|
assert response == {
|
|
"users": [extract_basic_user_info({"id": "U12345"})],
|
|
"next_cursor": None,
|
|
}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_users_with_pagination_success(mock_context, mock_slack_client):
|
|
mock_slack_client.users_list.side_effect = [
|
|
{
|
|
"ok": True,
|
|
"members": [{"id": "U12345"}],
|
|
"response_metadata": {"next_cursor": "cursor_xyz"},
|
|
},
|
|
{
|
|
"ok": True,
|
|
"members": [{"id": "U123456"}],
|
|
"response_metadata": {"next_cursor": None},
|
|
},
|
|
]
|
|
response = await list_users(mock_context, limit=3)
|
|
assert response == {
|
|
"users": [
|
|
extract_basic_user_info({"id": "U12345"}),
|
|
extract_basic_user_info({"id": "U123456"}),
|
|
],
|
|
"next_cursor": None,
|
|
}
|