mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
f9f5626ca4
**Description:** Bugfix: Langchain_community's GitHub Api wrapper throws a TypeError when searching for issues and/or PRs (the `search_issues_and_prs` method). This is because PyGithub's PageinatedList type does not support the len() method. See https://github.com/PyGithub/PyGithub/issues/1476 ![image](https://github.com/langchain-ai/langchain/assets/8849021/57390b11-ed41-4f48-ba50-f3028610789c) **Dependencies:** None **Twitter handle**: @ChrisKeoghNZ I haven't registered an issue as it would take me longer to fill the template out than to make the fix, but I'm happy to if that's deemed essential. I've added a simple integration test to cover this as there were no existing unit tests and it was going to be tricky to set them up. Co-authored-by: Chris Keogh <chris.keogh@xero.com>
28 lines
719 B
Python
28 lines
719 B
Python
"""Integration test for Github Wrapper."""
|
|
import pytest
|
|
|
|
from langchain_community.utilities.github import GitHubAPIWrapper
|
|
|
|
# Make sure you have set the following env variables:
|
|
# GITHUB_REPOSITORY
|
|
# GITHUB_BRANCH
|
|
# GITHUB_APP_ID
|
|
# GITHUB_PRIVATE_KEY
|
|
|
|
|
|
@pytest.fixture
|
|
def api_client() -> GitHubAPIWrapper:
|
|
return GitHubAPIWrapper()
|
|
|
|
|
|
def test_get_open_issues(api_client: GitHubAPIWrapper) -> None:
|
|
"""Basic test to fetch issues"""
|
|
issues = api_client.get_issues()
|
|
assert len(issues) != 0
|
|
|
|
|
|
def test_search_issues_and_prs(api_client: GitHubAPIWrapper) -> None:
|
|
"""Basic test to search issues and PRs"""
|
|
results = api_client.search_issues_and_prs("is:pr is:merged")
|
|
assert len(results) != 0
|