forked from ComposioHQ/composio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_load_tools.py
63 lines (54 loc) · 1.56 KB
/
test_load_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
E2E Tests for plugin demos and examples.
"""
import importlib
import os
from unittest import mock
import pytest
from composio import Action
from composio.exceptions import ComposioSDKError
# Plugin test definitions
PLUGINS = (
"autogen",
"camel",
"claude",
"crewai",
# "griptape", # TODO(@kaavee315): Handle oneOf in Griptape
# "julep", # TODO: Update the julep plugin implementation
"langchain",
"llamaindex",
"lyzr",
"openai",
"langgraph",
"phidata",
)
@pytest.mark.skipif(
condition=os.environ.get("CI", "false") == "true",
reason="Testing in CI will lead to too much LLM API usage",
)
@pytest.mark.parametrize("plugin", PLUGINS)
def test_load_tools(plugin: str) -> None:
"""Test an example with given environment."""
plugin_to_test = os.getenv("PLUGIN_TO_TEST")
if plugin_to_test is not None and plugin_to_test != plugin:
pytest.skip(f"Skipping {plugin}")
toolset = importlib.import_module(f"composio_{plugin}").ComposioToolSet()
actions = []
for action in Action.all():
try:
action.load()
actions.append(action)
except ComposioSDKError:
continue
with (
mock.patch.object(toolset, "check_connected_account"),
mock.patch.object(toolset, "validate_tools"),
):
if plugin == "autogen":
toolset.register_tools(
actions=actions,
caller=mock.MagicMock(),
executor=mock.MagicMock(),
)
else:
toolset.get_tools(actions=actions)