mirror of
https://github.com/hwchase17/langchain
synced 2024-11-11 19:11:02 +00:00
f2782f4c86
- **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>
19 lines
622 B
Python
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
|