### 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>
225 lines
7.2 KiB
Python
225 lines
7.2 KiB
Python
from collections.abc import Callable
|
|
|
|
import httpx
|
|
import pytest
|
|
from arcade_tdk import ToolContext
|
|
|
|
from arcade_jira.exceptions import NotFoundError
|
|
from arcade_jira.utils import clean_priority_dict, find_priorities_by_project
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_find_priorities_by_project_with_no_priority_schemes(
|
|
mock_context: ToolContext,
|
|
mock_httpx_client,
|
|
mock_httpx_response: Callable,
|
|
):
|
|
list_priority_schemes_response = mock_httpx_response(
|
|
200,
|
|
{
|
|
"values": [],
|
|
"isLast": True,
|
|
},
|
|
)
|
|
mock_httpx_client.get.return_value = list_priority_schemes_response
|
|
|
|
with pytest.raises(NotFoundError) as exc:
|
|
await find_priorities_by_project(mock_context, {})
|
|
|
|
assert "No priority schemes found" in exc.value.message
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_find_priorities_by_project_when_project_does_not_exist(
|
|
mock_context: ToolContext,
|
|
mock_httpx_client,
|
|
mock_httpx_response: Callable,
|
|
build_project_dict: Callable,
|
|
build_priority_scheme_dict: Callable,
|
|
):
|
|
sample_project = build_project_dict()
|
|
priority_scheme = build_priority_scheme_dict()
|
|
list_priority_schemes_response = mock_httpx_response(
|
|
200,
|
|
{"values": [priority_scheme], "isLast": True},
|
|
)
|
|
|
|
find_project_by_id_response = mock_httpx_response(404, {})
|
|
search_projects_response = mock_httpx_response(200, {"values": [], "isLast": True})
|
|
|
|
mock_httpx_client.get.side_effect = [
|
|
list_priority_schemes_response,
|
|
find_project_by_id_response,
|
|
search_projects_response,
|
|
]
|
|
|
|
response = await find_priorities_by_project(mock_context, sample_project)
|
|
|
|
assert response == {"error": f"Project not found with name/key/ID '{sample_project['id']}'"}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_find_priorities_by_project_when_project_is_found_but_does_not_match_id(
|
|
mock_context: ToolContext,
|
|
mock_httpx_client,
|
|
mock_httpx_response: Callable,
|
|
build_project_dict: Callable,
|
|
build_priority_scheme_dict: Callable,
|
|
):
|
|
sample_project = build_project_dict()
|
|
other_project = build_project_dict(name=sample_project["name"])
|
|
|
|
priority_scheme = build_priority_scheme_dict()
|
|
list_priority_schemes_response = mock_httpx_response(
|
|
200,
|
|
{"values": [priority_scheme], "isLast": True},
|
|
)
|
|
|
|
find_project_by_id_response = mock_httpx_response(404, {})
|
|
|
|
search_projects_response = mock_httpx_response(
|
|
200,
|
|
{"values": [other_project], "isLast": True},
|
|
)
|
|
|
|
list_projects_response = mock_httpx_response(
|
|
200,
|
|
{"values": [other_project], "isLast": True},
|
|
)
|
|
|
|
mock_httpx_client.get.side_effect = [
|
|
list_priority_schemes_response,
|
|
find_project_by_id_response,
|
|
search_projects_response,
|
|
list_projects_response,
|
|
]
|
|
|
|
response = await find_priorities_by_project(mock_context, sample_project)
|
|
|
|
assert response == {
|
|
"error": f"No priority schemes found for the project {sample_project['id']}"
|
|
}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_find_priorities_by_project_happy_path(
|
|
mock_context: ToolContext,
|
|
mock_httpx_client,
|
|
mock_httpx_response: Callable,
|
|
build_project_dict: Callable,
|
|
build_priority_dict: Callable,
|
|
build_priority_scheme_dict: Callable,
|
|
):
|
|
sample_project = build_project_dict()
|
|
other_project = build_project_dict(name=sample_project["name"])
|
|
|
|
priority_scheme = build_priority_scheme_dict()
|
|
priority1 = build_priority_dict()
|
|
priority2 = build_priority_dict()
|
|
|
|
list_priority_schemes_response = mock_httpx_response(
|
|
200,
|
|
{"values": [priority_scheme], "isLast": True},
|
|
)
|
|
|
|
find_project_by_id_response = mock_httpx_response(404, {})
|
|
|
|
search_projects_response = mock_httpx_response(
|
|
200,
|
|
{"values": [sample_project], "isLast": True},
|
|
)
|
|
|
|
list_projects_response = mock_httpx_response(
|
|
200,
|
|
{"values": [sample_project, other_project], "isLast": True},
|
|
)
|
|
|
|
list_priorities_response = mock_httpx_response(
|
|
200,
|
|
{"values": [priority1, priority2], "isLast": True},
|
|
)
|
|
|
|
mock_httpx_client.get.side_effect = [
|
|
list_priority_schemes_response,
|
|
find_project_by_id_response,
|
|
search_projects_response,
|
|
list_projects_response,
|
|
list_priorities_response,
|
|
]
|
|
|
|
response = await find_priorities_by_project(mock_context, sample_project)
|
|
|
|
assert response["priorities_available"] == [
|
|
clean_priority_dict(priority1),
|
|
clean_priority_dict(priority2),
|
|
]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_find_priorities_by_project_happy_path_with_repeated_priorities_across_schemes(
|
|
mock_context: ToolContext,
|
|
mock_httpx_client,
|
|
mock_httpx_response: Callable,
|
|
build_project_dict: Callable,
|
|
build_priority_dict: Callable,
|
|
build_priority_scheme_dict: Callable,
|
|
):
|
|
sample_project = build_project_dict()
|
|
other_project = build_project_dict(name=sample_project["name"])
|
|
|
|
priority_scheme1 = build_priority_scheme_dict()
|
|
priority_scheme2 = build_priority_scheme_dict()
|
|
|
|
priority1 = build_priority_dict()
|
|
priority2 = build_priority_dict()
|
|
priority3 = build_priority_dict()
|
|
|
|
list_priority_schemes_response = mock_httpx_response(
|
|
200,
|
|
{"values": [priority_scheme1, priority_scheme2], "isLast": True},
|
|
)
|
|
|
|
find_project_by_id_response = mock_httpx_response(200, sample_project)
|
|
|
|
list_projects_by_priority_scheme_response1 = mock_httpx_response(
|
|
200,
|
|
{"values": [sample_project, other_project], "isLast": True},
|
|
)
|
|
list_projects_by_priority_scheme_response2 = mock_httpx_response(
|
|
200,
|
|
{"values": [sample_project], "isLast": True},
|
|
)
|
|
|
|
list_priorities_by_scheme_response1 = mock_httpx_response(
|
|
200,
|
|
{"values": [priority1, priority2], "isLast": True},
|
|
)
|
|
list_priorities_by_scheme_response2 = mock_httpx_response(
|
|
200,
|
|
{"values": [priority2, priority3], "isLast": True},
|
|
)
|
|
|
|
def get_httpx_response(url: str, *args, **kwargs) -> httpx.Response:
|
|
if url.endswith("/priorityscheme"):
|
|
return list_priority_schemes_response
|
|
elif url.endswith(f"/project/{sample_project['id']}"):
|
|
return find_project_by_id_response
|
|
elif url.endswith(f"/priorityscheme/{priority_scheme1['id']}/projects"):
|
|
return list_projects_by_priority_scheme_response1
|
|
elif url.endswith(f"/priorityscheme/{priority_scheme2['id']}/projects"):
|
|
return list_projects_by_priority_scheme_response2
|
|
elif url.endswith(f"/priorityscheme/{priority_scheme1['id']}/priorities"):
|
|
return list_priorities_by_scheme_response1
|
|
elif url.endswith(f"/priorityscheme/{priority_scheme2['id']}/priorities"):
|
|
return list_priorities_by_scheme_response2
|
|
else:
|
|
raise ValueError(f"Unexpected URL: {url}") # noqa: TRY003
|
|
|
|
mock_httpx_client.get.side_effect = get_httpx_response
|
|
|
|
response = await find_priorities_by_project(mock_context, sample_project)
|
|
|
|
assert len(response["priorities_available"]) == 3
|
|
assert clean_priority_dict(priority1) in response["priorities_available"]
|
|
assert clean_priority_dict(priority2) in response["priorities_available"]
|
|
assert clean_priority_dict(priority3) in response["priorities_available"]
|