langchain/libs/community/tests/unit_tests/tools/gmail/test_send.py
ccurme f2782f4c86
community: add args_schema to GmailSendMessage (#14973)
- **Description:** `tools.gmail.send_message` implements a
`SendMessageSchema` that is not used anywhere. `GmailSendMessage` also
does not have an `args_schema` attribute (this led to issues when
invoking the tool with an OpenAI functions agent, at least for me). Here
we add the missing attribute and a minimal test for the tool.
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Twitter handle:** N/A

---------

Co-authored-by: Chester Curme <chestercurme@microsoft.com>
2023-12-22 13:07:44 -08:00

19 lines
622 B
Python

from unittest.mock import MagicMock
from langchain_community.tools.gmail.send_message import GmailSendMessage
def test_send() -> None:
"""Test gmail send."""
mock_api_resource = MagicMock()
# bypass pydantic validation as google-api-python-client is not a package dependency
tool = GmailSendMessage.construct(api_resource=mock_api_resource)
tool_input = {
"to": "fake123@email.com",
"subject": "subject line",
"message": "message body",
}
result = tool.run(tool_input)
assert result.startswith("Message sent. Message Id:")
assert tool.args_schema is not None