test_file_search.py — langchain Source File
Architecture documentation for test_file_search.py, a python file in the langchain codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 882602ab_3eb6_c4cf_b94d_d1eb905b93f5["test_file_search.py"] 445c3432_646a_9252_69ac_429a25f2798a["langchain_anthropic.middleware.anthropic_tools"] 882602ab_3eb6_c4cf_b94d_d1eb905b93f5 --> 445c3432_646a_9252_69ac_429a25f2798a 17cda4af_1917_190d_b233_3d3495cbab9b["langchain_anthropic.middleware.file_search"] 882602ab_3eb6_c4cf_b94d_d1eb905b93f5 --> 17cda4af_1917_190d_b233_3d3495cbab9b style 882602ab_3eb6_c4cf_b94d_d1eb905b93f5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Unit tests for file search middleware."""
from langchain_anthropic.middleware.anthropic_tools import AnthropicToolsState
from langchain_anthropic.middleware.file_search import (
StateFileSearchMiddleware,
)
class TestSearchMiddlewareInitialization:
"""Test search middleware initialization."""
def test_middleware_initialization(self) -> None:
"""Test middleware initializes correctly."""
middleware = StateFileSearchMiddleware()
assert middleware.state_schema == AnthropicToolsState
assert middleware.state_key == "text_editor_files"
def test_custom_state_key(self) -> None:
"""Test middleware with custom state key."""
middleware = StateFileSearchMiddleware(state_key="memory_files")
assert middleware.state_key == "memory_files"
class TestGlobSearch:
"""Test Glob file pattern matching."""
def test_glob_basic_pattern(self) -> None:
"""Test basic glob pattern matching."""
middleware = StateFileSearchMiddleware()
test_state: AnthropicToolsState = {
"messages": [],
"text_editor_files": {
"/src/main.py": {
"content": ["print('hello')"],
"created_at": "2025-01-01T00:00:00",
"modified_at": "2025-01-01T00:00:00",
},
"/src/utils.py": {
"content": ["def helper(): pass"],
"created_at": "2025-01-01T00:00:00",
"modified_at": "2025-01-01T00:00:00",
},
"/README.md": {
"content": ["# Project"],
"created_at": "2025-01-01T00:00:00",
"modified_at": "2025-01-01T00:00:00",
},
},
}
# Call internal handler method directly
result = middleware._handle_glob_search(
pattern="*.py", path="/", state=test_state
)
assert isinstance(result, str)
assert "/src/main.py" in result
assert "/src/utils.py" in result
assert "/README.md" not in result
// ... (490 more lines)
Domain
Subdomains
Classes
Dependencies
- langchain_anthropic.middleware.anthropic_tools
- langchain_anthropic.middleware.file_search
Source
Frequently Asked Questions
What does test_file_search.py do?
test_file_search.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What does test_file_search.py depend on?
test_file_search.py imports 2 module(s): langchain_anthropic.middleware.anthropic_tools, langchain_anthropic.middleware.file_search.
Where is test_file_search.py in the architecture?
test_file_search.py is located at libs/partners/anthropic/tests/unit_tests/middleware/test_file_search.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/partners/anthropic/tests/unit_tests/middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free