Skip to content

Commit

Permalink
test: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Dec 31, 2024
1 parent 5027da1 commit 5dc452a
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions python/tests/test_tools/test_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from composio.exceptions import ApiKeyNotProvidedError, ComposioSDKError
from composio.tools.base.abs import action_registry, tool_registry
from composio.tools.base.runtime import action as custom_action
from composio.tools.local.filetool.tool import Filetool, FindFile
from composio.tools.toolset import ComposioToolSet
from composio.utils.pypi import reset_installed_list

Expand Down Expand Up @@ -331,6 +332,61 @@ def test_execute_action_param_serialization() -> None:
)


def test_custom_auth_on_localtool():
toolset = ComposioToolSet()
toolset.add_auth(
app=Filetool.enum,
parameters=[
{
"in_": "metadata",
"name": "name",
"value": "value",
}
],
)

def _execute(cls, request, metadata): # pylint: disable=unused-argument
return mock.MagicMock(
model_dump=lambda *_: {
"assert": metadata["name"] == "value",
},
)

with mock.patch.object(FindFile, "execute", new=_execute):
response = toolset.execute_action(
action=FindFile.enum,
params={
"pattern": "*.py",
},
)
assert response["data"]["assert"]


def test_bad_custom_auth_on_localtool():
toolset = ComposioToolSet()
toolset.add_auth(
app=Filetool.enum,
parameters=[
{
"in_": "query",
"name": "name",
"value": "value",
}
],
)

with pytest.raises(
ComposioSDKError,
match="Invalid custom auth found for FILETOOL",
):
toolset.execute_action(
action=FindFile.enum,
params={
"pattern": "*.py",
},
)


class TestSubclassInit:

def test_runtime(self):
Expand Down

0 comments on commit 5dc452a

Please sign in to comment.