test_tools.py — langchain Source File
Architecture documentation for test_tools.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d59061e5_8103_862f_4af9_770edb6e5f3a["test_tools.py"] 23cb242e_1754_041d_200a_553fcb8abe1b["unittest.mock"] d59061e5_8103_862f_4af9_770edb6e5f3a --> 23cb242e_1754_041d_200a_553fcb8abe1b eb5ed5ef_e1a1_2b04_ea56_09bddf618738["pytest_mock"] d59061e5_8103_862f_4af9_770edb6e5f3a --> eb5ed5ef_e1a1_2b04_ea56_09bddf618738 f5d04cf8_4a62_746d_5fb8_3a2187481e62["langchain_perplexity"] d59061e5_8103_862f_4af9_770edb6e5f3a --> f5d04cf8_4a62_746d_5fb8_3a2187481e62 style d59061e5_8103_862f_4af9_770edb6e5f3a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from unittest.mock import MagicMock
from pytest_mock import MockerFixture
from langchain_perplexity import PerplexitySearchResults
def test_search_tool_run(mocker: MockerFixture) -> None:
tool = PerplexitySearchResults(pplx_api_key="test")
mock_result = MagicMock()
mock_result.title = "Test Title"
mock_result.url = "http://test.com"
mock_result.snippet = "Test snippet"
mock_result.date = "2023-01-01"
mock_result.last_updated = "2023-01-02"
mock_response = MagicMock()
mock_response.results = [mock_result]
mock_create = MagicMock(return_value=mock_response)
mocker.patch.object(tool.client.search, "create", mock_create)
result = tool.invoke("query")
# result should be a list of dicts (converted by tool) or str if string output
# By default, tool.invoke returns the output of _run.
assert isinstance(result, list)
assert len(result) == 1
assert result[0]["title"] == "Test Title"
mock_create.assert_called_once_with(
query="query",
max_results=10,
)
Domain
Subdomains
Functions
Dependencies
- langchain_perplexity
- pytest_mock
- unittest.mock
Source
Frequently Asked Questions
What does test_tools.py do?
test_tools.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What functions are defined in test_tools.py?
test_tools.py defines 1 function(s): test_search_tool_run.
What does test_tools.py depend on?
test_tools.py imports 3 module(s): langchain_perplexity, pytest_mock, unittest.mock.
Where is test_tools.py in the architecture?
test_tools.py is located at libs/partners/perplexity/tests/unit_tests/test_tools.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/partners/perplexity/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free