cortexflow-github 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cortexflow_github-0.1.0/LICENSE +21 -0
- cortexflow_github-0.1.0/PKG-INFO +45 -0
- cortexflow_github-0.1.0/README.md +29 -0
- cortexflow_github-0.1.0/pyproject.toml +31 -0
- cortexflow_github-0.1.0/setup.cfg +4 -0
- cortexflow_github-0.1.0/src/cortexflow_github/__init__.py +7 -0
- cortexflow_github-0.1.0/src/cortexflow_github/plugin.py +28 -0
- cortexflow_github-0.1.0/src/cortexflow_github/tool.py +56 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/PKG-INFO +45 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/SOURCES.txt +14 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/dependency_links.txt +1 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/entry_points.txt +2 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/requires.txt +6 -0
- cortexflow_github-0.1.0/src/cortexflow_github.egg-info/top_level.txt +1 -0
- cortexflow_github-0.1.0/tests/test_plugin.py +37 -0
- cortexflow_github-0.1.0/tests/test_tool.py +112 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amit Chandra
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cortexflow-github
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CortexFlow plugin — list recent GitHub repository events (pushes, PRs, issues).
|
|
5
|
+
Author-email: Amit Chandra <amit.vervebot@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: cortexflow-sdk>=0.1.0
|
|
11
|
+
Requires-Dist: httpx>=0.27.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8.2.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# cortexflow-github
|
|
18
|
+
|
|
19
|
+
Example CortexFlow plugin: a `github_events` tool that lists recent events
|
|
20
|
+
(pushes, PRs, issues) for a GitHub repository via the public REST API.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e ./cortexflow-sdk # not yet on PyPI
|
|
26
|
+
pip install -e examples/plugins/cortexflow-github
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Set `GITHUB_TOKEN` in your environment for authenticated requests (raises the
|
|
32
|
+
rate limit from 60/hr to 5000/hr) — optional, the tool works without it.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from cortexflow_github import GitHubEventsTool
|
|
36
|
+
|
|
37
|
+
tool = GitHubEventsTool()
|
|
38
|
+
result = await tool.execute(owner="TheAmitChandra", repo="CortexFlow", limit=5)
|
|
39
|
+
print(result.output)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Once installed alongside the CortexFlow gateway, `cortex plugin add
|
|
43
|
+
cortexflow-github` (or simply having it installed in the same environment)
|
|
44
|
+
makes `PluginRegistry.discover()` find it via the `cortexflow.plugins` entry
|
|
45
|
+
point declared in `pyproject.toml`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# cortexflow-github
|
|
2
|
+
|
|
3
|
+
Example CortexFlow plugin: a `github_events` tool that lists recent events
|
|
4
|
+
(pushes, PRs, issues) for a GitHub repository via the public REST API.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install -e ./cortexflow-sdk # not yet on PyPI
|
|
10
|
+
pip install -e examples/plugins/cortexflow-github
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Set `GITHUB_TOKEN` in your environment for authenticated requests (raises the
|
|
16
|
+
rate limit from 60/hr to 5000/hr) — optional, the tool works without it.
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from cortexflow_github import GitHubEventsTool
|
|
20
|
+
|
|
21
|
+
tool = GitHubEventsTool()
|
|
22
|
+
result = await tool.execute(owner="TheAmitChandra", repo="CortexFlow", limit=5)
|
|
23
|
+
print(result.output)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Once installed alongside the CortexFlow gateway, `cortex plugin add
|
|
27
|
+
cortexflow-github` (or simply having it installed in the same environment)
|
|
28
|
+
makes `PluginRegistry.discover()` find it via the `cortexflow.plugins` entry
|
|
29
|
+
point declared in `pyproject.toml`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cortexflow-github"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CortexFlow plugin — list recent GitHub repository events (pushes, PRs, issues)."
|
|
9
|
+
authors = [{ name = "Amit Chandra", email = "amit.vervebot@gmail.com" }]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
license = { text = "MIT" }
|
|
13
|
+
dependencies = [
|
|
14
|
+
"cortexflow-sdk>=0.1.0",
|
|
15
|
+
"httpx>=0.27.0",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
dev = [
|
|
20
|
+
"pytest>=8.2.0",
|
|
21
|
+
"pytest-asyncio>=0.23.0",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.entry-points."cortexflow.plugins"]
|
|
25
|
+
cortexflow-github = "cortexflow_github.plugin:GitHubPlugin"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["src"]
|
|
29
|
+
|
|
30
|
+
[tool.pytest.ini_options]
|
|
31
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""GitHubPlugin — registers GitHubEventsTool with the CortexFlow gateway."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from cortexflow_sdk import Plugin, PluginMetadata
|
|
8
|
+
|
|
9
|
+
from cortexflow_github.tool import GitHubEventsTool
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class GitHubPlugin(Plugin):
|
|
13
|
+
"""Adds a github_events tool. Reads GITHUB_TOKEN from the environment."""
|
|
14
|
+
|
|
15
|
+
metadata = PluginMetadata(
|
|
16
|
+
name="cortexflow-github",
|
|
17
|
+
version="0.1.0",
|
|
18
|
+
plugin_type="tool",
|
|
19
|
+
description="List recent GitHub repository events (pushes, PRs, issues).",
|
|
20
|
+
permissions=["network"],
|
|
21
|
+
homepage="https://github.com/TheAmitChandra/CortexFlow",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def __init__(self) -> None:
|
|
25
|
+
self._token = os.getenv("GITHUB_TOKEN")
|
|
26
|
+
|
|
27
|
+
def get_tools(self):
|
|
28
|
+
return [GitHubEventsTool(token=self._token)]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""GitHubEventsTool — lists recent public events for a GitHub repository."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from cortexflow_sdk import Tool, ToolResult
|
|
6
|
+
|
|
7
|
+
_API_URL = "https://api.github.com/repos/{owner}/{repo}/events"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GitHubEventsTool(Tool):
|
|
11
|
+
"""Fetches recent events (pushes, PRs, issues, stars) for a repo."""
|
|
12
|
+
|
|
13
|
+
name = "github_events"
|
|
14
|
+
description = "List recent GitHub events (pushes, PRs, issues) for a repository."
|
|
15
|
+
parameters = {
|
|
16
|
+
"owner": {"type": "str", "description": "Repository owner/org", "required": True},
|
|
17
|
+
"repo": {"type": "str", "description": "Repository name", "required": True},
|
|
18
|
+
"limit": {"type": "int", "description": "Max events to return (default 10)", "required": False},
|
|
19
|
+
}
|
|
20
|
+
permissions = ["network"]
|
|
21
|
+
|
|
22
|
+
def __init__(self, token: str | None = None) -> None:
|
|
23
|
+
self._token = token
|
|
24
|
+
|
|
25
|
+
async def execute(self, owner: str, repo: str, limit: int = 10, **_) -> ToolResult:
|
|
26
|
+
try:
|
|
27
|
+
import httpx
|
|
28
|
+
except ImportError:
|
|
29
|
+
return ToolResult(tool=self.name, output=None, error="pip install httpx")
|
|
30
|
+
|
|
31
|
+
headers = {"Authorization": f"Bearer {self._token}"} if self._token else {}
|
|
32
|
+
url = _API_URL.format(owner=owner, repo=repo)
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
async with httpx.AsyncClient() as client:
|
|
36
|
+
resp = await client.get(
|
|
37
|
+
url, headers=headers, params={"per_page": min(limit, 100)}, timeout=10.0,
|
|
38
|
+
)
|
|
39
|
+
resp.raise_for_status()
|
|
40
|
+
events = resp.json()
|
|
41
|
+
except Exception as exc:
|
|
42
|
+
return ToolResult(tool=self.name, output=None, error=str(exc))
|
|
43
|
+
|
|
44
|
+
formatted = [
|
|
45
|
+
{
|
|
46
|
+
"type": e.get("type", "Unknown"),
|
|
47
|
+
"actor": (e.get("actor") or {}).get("login", "unknown"),
|
|
48
|
+
"created_at": e.get("created_at", ""),
|
|
49
|
+
}
|
|
50
|
+
for e in events[:limit]
|
|
51
|
+
]
|
|
52
|
+
return ToolResult(
|
|
53
|
+
tool=self.name,
|
|
54
|
+
output=formatted,
|
|
55
|
+
metadata={"repo": f"{owner}/{repo}", "count": len(formatted)},
|
|
56
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cortexflow-github
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CortexFlow plugin — list recent GitHub repository events (pushes, PRs, issues).
|
|
5
|
+
Author-email: Amit Chandra <amit.vervebot@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: cortexflow-sdk>=0.1.0
|
|
11
|
+
Requires-Dist: httpx>=0.27.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8.2.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# cortexflow-github
|
|
18
|
+
|
|
19
|
+
Example CortexFlow plugin: a `github_events` tool that lists recent events
|
|
20
|
+
(pushes, PRs, issues) for a GitHub repository via the public REST API.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install -e ./cortexflow-sdk # not yet on PyPI
|
|
26
|
+
pip install -e examples/plugins/cortexflow-github
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Set `GITHUB_TOKEN` in your environment for authenticated requests (raises the
|
|
32
|
+
rate limit from 60/hr to 5000/hr) — optional, the tool works without it.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from cortexflow_github import GitHubEventsTool
|
|
36
|
+
|
|
37
|
+
tool = GitHubEventsTool()
|
|
38
|
+
result = await tool.execute(owner="TheAmitChandra", repo="CortexFlow", limit=5)
|
|
39
|
+
print(result.output)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Once installed alongside the CortexFlow gateway, `cortex plugin add
|
|
43
|
+
cortexflow-github` (or simply having it installed in the same environment)
|
|
44
|
+
makes `PluginRegistry.discover()` find it via the `cortexflow.plugins` entry
|
|
45
|
+
point declared in `pyproject.toml`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/cortexflow_github/__init__.py
|
|
5
|
+
src/cortexflow_github/plugin.py
|
|
6
|
+
src/cortexflow_github/tool.py
|
|
7
|
+
src/cortexflow_github.egg-info/PKG-INFO
|
|
8
|
+
src/cortexflow_github.egg-info/SOURCES.txt
|
|
9
|
+
src/cortexflow_github.egg-info/dependency_links.txt
|
|
10
|
+
src/cortexflow_github.egg-info/entry_points.txt
|
|
11
|
+
src/cortexflow_github.egg-info/requires.txt
|
|
12
|
+
src/cortexflow_github.egg-info/top_level.txt
|
|
13
|
+
tests/test_plugin.py
|
|
14
|
+
tests/test_tool.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cortexflow_github
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Unit tests for cortexflow_github.plugin — GitHubPlugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from cortexflow_github.plugin import GitHubPlugin
|
|
6
|
+
from cortexflow_github.tool import GitHubEventsTool
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_plugin_metadata():
|
|
10
|
+
p = GitHubPlugin()
|
|
11
|
+
assert p.metadata.name == "cortexflow-github"
|
|
12
|
+
assert p.metadata.plugin_type == "tool"
|
|
13
|
+
assert "network" in p.metadata.permissions
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_plugin_reads_token_from_env(monkeypatch):
|
|
17
|
+
monkeypatch.setenv("GITHUB_TOKEN", "ghp_fromenv")
|
|
18
|
+
p = GitHubPlugin()
|
|
19
|
+
assert p._token == "ghp_fromenv"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_plugin_no_token_in_env(monkeypatch):
|
|
23
|
+
monkeypatch.delenv("GITHUB_TOKEN", raising=False)
|
|
24
|
+
p = GitHubPlugin()
|
|
25
|
+
assert p._token is None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_get_tools_returns_github_events_tool():
|
|
29
|
+
tools = GitHubPlugin().get_tools()
|
|
30
|
+
assert len(tools) == 1
|
|
31
|
+
assert isinstance(tools[0], GitHubEventsTool)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_get_tools_tool_carries_plugin_token(monkeypatch):
|
|
35
|
+
monkeypatch.setenv("GITHUB_TOKEN", "ghp_carried")
|
|
36
|
+
tool = GitHubPlugin().get_tools()[0]
|
|
37
|
+
assert tool._token == "ghp_carried"
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Unit tests for cortexflow_github.tool — GitHubEventsTool."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from unittest.mock import AsyncMock, MagicMock, patch
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from cortexflow_github.tool import GitHubEventsTool
|
|
9
|
+
|
|
10
|
+
_SAMPLE_EVENTS = [
|
|
11
|
+
{"type": "PushEvent", "actor": {"login": "alice"}, "created_at": "2026-06-26T10:00:00Z"},
|
|
12
|
+
{"type": "IssuesEvent", "actor": {"login": "bob"}, "created_at": "2026-06-26T09:00:00Z"},
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _make_mock_client(json_body, raise_on_status: Exception | None = None):
|
|
17
|
+
mock_resp = MagicMock()
|
|
18
|
+
mock_resp.raise_for_status = MagicMock(side_effect=raise_on_status)
|
|
19
|
+
mock_resp.json = MagicMock(return_value=json_body)
|
|
20
|
+
|
|
21
|
+
mock_client = MagicMock()
|
|
22
|
+
mock_client.__aenter__ = AsyncMock(return_value=mock_client)
|
|
23
|
+
mock_client.__aexit__ = AsyncMock(return_value=False)
|
|
24
|
+
mock_client.get = AsyncMock(return_value=mock_resp)
|
|
25
|
+
return mock_client
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.asyncio
|
|
29
|
+
async def test_execute_returns_formatted_events():
|
|
30
|
+
tool = GitHubEventsTool()
|
|
31
|
+
mock_client = _make_mock_client(_SAMPLE_EVENTS)
|
|
32
|
+
|
|
33
|
+
with patch("httpx.AsyncClient", return_value=mock_client):
|
|
34
|
+
result = await tool.execute(owner="TheAmitChandra", repo="CortexFlow", limit=10)
|
|
35
|
+
|
|
36
|
+
assert result.success
|
|
37
|
+
assert len(result.output) == 2
|
|
38
|
+
assert result.output[0]["actor"] == "alice"
|
|
39
|
+
assert result.metadata["repo"] == "TheAmitChandra/CortexFlow"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.mark.asyncio
|
|
43
|
+
async def test_execute_respects_limit():
|
|
44
|
+
tool = GitHubEventsTool()
|
|
45
|
+
mock_client = _make_mock_client(_SAMPLE_EVENTS)
|
|
46
|
+
|
|
47
|
+
with patch("httpx.AsyncClient", return_value=mock_client):
|
|
48
|
+
result = await tool.execute(owner="o", repo="r", limit=1)
|
|
49
|
+
|
|
50
|
+
assert len(result.output) == 1
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.asyncio
|
|
54
|
+
async def test_execute_sends_auth_header_when_token_set():
|
|
55
|
+
tool = GitHubEventsTool(token="ghp_secret")
|
|
56
|
+
mock_client = _make_mock_client(_SAMPLE_EVENTS)
|
|
57
|
+
|
|
58
|
+
with patch("httpx.AsyncClient", return_value=mock_client):
|
|
59
|
+
await tool.execute(owner="o", repo="r")
|
|
60
|
+
|
|
61
|
+
call_kwargs = mock_client.get.call_args[1]
|
|
62
|
+
assert call_kwargs["headers"]["Authorization"] == "Bearer ghp_secret"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@pytest.mark.asyncio
|
|
66
|
+
async def test_execute_no_token_omits_auth_header():
|
|
67
|
+
tool = GitHubEventsTool()
|
|
68
|
+
mock_client = _make_mock_client(_SAMPLE_EVENTS)
|
|
69
|
+
|
|
70
|
+
with patch("httpx.AsyncClient", return_value=mock_client):
|
|
71
|
+
await tool.execute(owner="o", repo="r")
|
|
72
|
+
|
|
73
|
+
call_kwargs = mock_client.get.call_args[1]
|
|
74
|
+
assert call_kwargs["headers"] == {}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@pytest.mark.asyncio
|
|
78
|
+
async def test_execute_http_error_returns_error_result():
|
|
79
|
+
tool = GitHubEventsTool()
|
|
80
|
+
mock_client = _make_mock_client([], raise_on_status=RuntimeError("404 Not Found"))
|
|
81
|
+
|
|
82
|
+
with patch("httpx.AsyncClient", return_value=mock_client):
|
|
83
|
+
result = await tool.execute(owner="o", repo="missing")
|
|
84
|
+
|
|
85
|
+
assert not result.success
|
|
86
|
+
assert "404" in result.error
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@pytest.mark.asyncio
|
|
90
|
+
async def test_execute_missing_httpx_returns_error():
|
|
91
|
+
import builtins
|
|
92
|
+
|
|
93
|
+
real_import = builtins.__import__
|
|
94
|
+
|
|
95
|
+
def fake_import(name, *args, **kwargs):
|
|
96
|
+
if name == "httpx":
|
|
97
|
+
raise ImportError("No module named 'httpx'")
|
|
98
|
+
return real_import(name, *args, **kwargs)
|
|
99
|
+
|
|
100
|
+
tool = GitHubEventsTool()
|
|
101
|
+
with patch("builtins.__import__", side_effect=fake_import):
|
|
102
|
+
result = await tool.execute(owner="o", repo="r")
|
|
103
|
+
|
|
104
|
+
assert not result.success
|
|
105
|
+
assert "pip install httpx" in result.error
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_tool_schema_marks_owner_and_repo_required():
|
|
109
|
+
schema = GitHubEventsTool().get_schema()
|
|
110
|
+
assert "owner" in schema["parameters"]["required"]
|
|
111
|
+
assert "repo" in schema["parameters"]["required"]
|
|
112
|
+
assert "limit" not in schema["parameters"]["required"]
|