Home / Function/ test_view_operation() — langchain Function Reference

test_view_operation() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/partners/anthropic/tests/unit_tests/middleware/test_anthropic_tools.py lines 106–130

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

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

        args = {"command": "view", "path": "/test.txt"}
        result = middleware._handle_view(args, state, "test_id")

        assert isinstance(result, Command)
        assert result.update is not None
        messages = result.update.get("messages", [])
        assert len(messages) == 1
        assert isinstance(messages[0], ToolMessage)
        assert messages[0].content == "1|line1\n2|line2\n3|line3"
        assert messages[0].tool_call_id == "test_id"

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free