Home / Function/ test_insert_operation() — langchain Function Reference

test_insert_operation() — langchain Function Reference

Architecture documentation for the test_insert_operation() function in test_anthropic_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  13900572_2b4e_505d_2283_a8dae3bcae66["test_insert_operation()"]
  6ec57bb9_6c88_435d_d3c5_ccf498cb814d["TestFileOperations"]
  13900572_2b4e_505d_2283_a8dae3bcae66 -->|defined in| 6ec57bb9_6c88_435d_d3c5_ccf498cb814d
  style 13900572_2b4e_505d_2283_a8dae3bcae66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py lines 202–228

    def test_insert_operation(self) -> None:
        """Test insert command execution."""
        middleware = StateClaudeTextEditorMiddleware()

        state: AnthropicToolsState = {
            "messages": [],
            "text_editor_files": {
                "/test.txt": {
                    "content": ["line1", "line2"],
                    "created_at": "2025-01-01T00:00:00",
                    "modified_at": "2025-01-01T00:00:00",
                }
            },
        }

        args = {
            "command": "insert",
            "path": "/test.txt",
            "insert_line": 0,
            "new_str": "inserted",
        }
        result = middleware._handle_insert(args, state, "test_id")

        assert isinstance(result, Command)
        assert result.update is not None
        files = result.update.get("text_editor_files", {})
        assert files["/test.txt"]["content"] == ["inserted", "line1", "line2"]

Domain

Subdomains

Frequently Asked Questions

What does test_insert_operation() do?
test_insert_operation() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py.
Where is test_insert_operation() defined?
test_insert_operation() is defined in libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py at line 202.

Analyze Your Own Codebase

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

Try Supermodel Free