mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-25 04:49:17 +00:00
community: adds support for getting github releases for the configured repository (#29318)
**Description:** adds support for github tool to query github releases on the configure respository **Issue:** N/A **Dependencies:** N/A **Twitter handle:** @macsdickinson --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from langchain_community.agent_toolkits.github.toolkit import GitHubToolkit
|
||||
from langchain_community.utilities.github import GitHubAPIWrapper
|
||||
|
||||
|
||||
def test_github_toolkit() -> None:
|
||||
# Create a mock GitHub wrapper with required attributes
|
||||
mock_github = MagicMock(spec=GitHubAPIWrapper)
|
||||
mock_github.github_repository = "fake/repo"
|
||||
mock_github.github_app_id = "fake_id"
|
||||
mock_github.github_app_private_key = "fake_key"
|
||||
mock_github.active_branch = "main"
|
||||
mock_github.github_base_branch = "main"
|
||||
|
||||
# Test without release tools
|
||||
toolkit = GitHubToolkit.from_github_api_wrapper(mock_github)
|
||||
tools = toolkit.get_tools()
|
||||
assert len(tools) == 21 # Base number of tools
|
||||
|
||||
# Test with release tools
|
||||
toolkit_with_releases = GitHubToolkit.from_github_api_wrapper(
|
||||
mock_github, include_release_tools=True
|
||||
)
|
||||
tools_with_releases = toolkit_with_releases.get_tools()
|
||||
assert len(tools_with_releases) == 24 # Base tools + 3 release tools
|
Reference in New Issue
Block a user