Home / Class/ TestFilesystemGlobSearch Class — langchain Architecture

TestFilesystemGlobSearch Class — langchain Architecture

Architecture documentation for the TestFilesystemGlobSearch class in test_file_search.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fedb24a7_5bdb_9630_456f_d159ddeadfa8["TestFilesystemGlobSearch"]
  5e183a7b_f937_e2fe_e90a_7c6aea33188b["StructuredTool"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|extends| 5e183a7b_f937_e2fe_e90a_7c6aea33188b
  fd751914_766d_3dc6_73f9_3e0a51985938["test_file_search.py"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|defined in| fd751914_766d_3dc6_73f9_3e0a51985938
  4674a157_70e8_5980_fce9_ec91fa4fefad["test_glob_basic_pattern()"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|method| 4674a157_70e8_5980_fce9_ec91fa4fefad
  30e85438_3cdc_a259_a464_c137181eef37["test_glob_recursive_pattern()"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|method| 30e85438_3cdc_a259_a464_c137181eef37
  9596cf87_6fea_194d_f408_8dcdd31cb2ff["test_glob_with_subdirectory_path()"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|method| 9596cf87_6fea_194d_f408_8dcdd31cb2ff
  2d60f92f_3006_376e_592e_4c8f7e8f2416["test_glob_no_matches()"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|method| 2d60f92f_3006_376e_592e_4c8f7e8f2416
  07ab0b02_054e_5c82_683e_5a3a4af71396["test_glob_invalid_path()"]
  fedb24a7_5bdb_9630_456f_d159ddeadfa8 -->|method| 07ab0b02_054e_5c82_683e_5a3a4af71396

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py lines 140–211

class TestFilesystemGlobSearch:
    """Tests for filesystem-backed glob search."""

    def test_glob_basic_pattern(self, tmp_path: Path) -> None:
        """Test basic glob pattern matching."""
        (tmp_path / "file1.py").write_text("content", encoding="utf-8")
        (tmp_path / "file2.py").write_text("content", encoding="utf-8")
        (tmp_path / "file3.txt").write_text("content", encoding="utf-8")

        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path))

        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="*.py")

        assert "/file1.py" in result
        assert "/file2.py" in result
        assert "/file3.txt" not in result

    def test_glob_recursive_pattern(self, tmp_path: Path) -> None:
        """Test recursive glob pattern matching."""
        (tmp_path / "src").mkdir()
        (tmp_path / "src" / "test.py").write_text("content", encoding="utf-8")
        (tmp_path / "src" / "nested").mkdir()
        (tmp_path / "src" / "nested" / "deep.py").write_text("content", encoding="utf-8")

        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path))

        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="**/*.py")

        assert "/src/test.py" in result
        assert "/src/nested/deep.py" in result

    def test_glob_with_subdirectory_path(self, tmp_path: Path) -> None:
        """Test glob search starting from subdirectory."""
        (tmp_path / "src").mkdir()
        (tmp_path / "src" / "file1.py").write_text("content", encoding="utf-8")
        (tmp_path / "other").mkdir()
        (tmp_path / "other" / "file2.py").write_text("content", encoding="utf-8")

        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path))

        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="*.py", path="/src")

        assert "/src/file1.py" in result
        assert "/other/file2.py" not in result

    def test_glob_no_matches(self, tmp_path: Path) -> None:
        """Test glob search with no matches."""
        (tmp_path / "file.txt").write_text("content", encoding="utf-8")

        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path))

        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="*.py")

        assert result == "No files found"

    def test_glob_invalid_path(self, tmp_path: Path) -> None:
        """Test glob search with non-existent path."""
        middleware = FilesystemFileSearchMiddleware(root_path=str(tmp_path))

        assert isinstance(middleware.glob_search, StructuredTool)
        assert middleware.glob_search.func is not None
        result = middleware.glob_search.func(pattern="*.py", path="/nonexistent")

        assert result == "No files found"

Extends

Frequently Asked Questions

What is the TestFilesystemGlobSearch class?
TestFilesystemGlobSearch is a class in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py.
Where is TestFilesystemGlobSearch defined?
TestFilesystemGlobSearch is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_file_search.py at line 140.
What does TestFilesystemGlobSearch extend?
TestFilesystemGlobSearch extends StructuredTool.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free