This PR introduces the `lookup_tweet_by_id` tool to the X toolkit,
enabling users to retrieve tweet details by tweet ID. This enhancement
extends the toolkit's capabilities, allowing for more comprehensive
interactions with the X (Twitter) API.
**Key Changes:**
- **Added `lookup_tweet_by_id` Tool:**
- Implemented the `lookup_tweet_by_id` function in `tools/tweets.py`,
which allows users to fetch tweet information using a tweet ID.
- Included error handling for API response codes and expanded URLs in
tweets to assist language models in avoiding hallucinations due to
shortened URLs.
- **Enhanced Toolkit Structure:**
- Added several configuration files to the X toolkit to establish a
standardized project structure, which in the future will be generated by
`arcade new`. These include:
- `.pre-commit-config.yaml`: Defines pre-commit hooks for code quality
checks.
- `.ruff.toml`: Configuration for the Ruff linter.
- `LICENSE`: MIT License file for the toolkit.
- `Makefile`: Contains common commands for building, testing, and
linting the toolkit.
- **Updated Makefile:**
- Added `make check-toolkits` command to the top-level `Makefile`. This
command runs code quality tools for each toolkit that contains a
`Makefile`.
**Additional Notes:**
- **Tests:**
- Added unit tests for the new `lookup_tweet_by_id` tool in
`tests/test_tweets.py`.
- Included tests for the user lookup functionality in
`tests/test_users.py`.
- **Linting and Code Quality:**
- Configured pre-commit hooks and Ruff linter to enforce code standards.
- Updated the `pyproject.toml` file with development dependencies for
testing and linting.
-
---------
Co-authored-by: Eric Gustin <eric@arcade-ai.com>
17 lines
546 B
Python
17 lines
546 B
Python
import pytest
|
|
from arcade.sdk import ToolContext
|
|
|
|
|
|
@pytest.fixture
|
|
def tool_context():
|
|
"""Fixture for the ToolContext with mock authorization."""
|
|
return ToolContext(authorization={"token": "test_token", "user_id": "test_user"})
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_httpx_client(mocker):
|
|
"""Fixture to mock the httpx.AsyncClient."""
|
|
# Mock the AsyncClient context manager
|
|
mock_client = mocker.patch("httpx.AsyncClient", autospec=True)
|
|
async_mock_client = mock_client.return_value.__aenter__.return_value
|
|
return async_mock_client
|