Home / Function/ mock_client() — langchain Function Reference

mock_client() — langchain Function Reference

Architecture documentation for the mock_client() function in test_base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8e1e4e08_fc96_d93c_7dfa_44c8ab3996ac["mock_client()"]
  48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"]
  8e1e4e08_fc96_d93c_7dfa_44c8ab3996ac -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5
  style 8e1e4e08_fc96_d93c_7dfa_44c8ab3996ac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 635–647

def mock_client(mock_completion: dict) -> MagicMock:
    rtn = MagicMock()

    mock_create = MagicMock()

    mock_resp = MagicMock()
    mock_resp.headers = {"content-type": "application/json"}
    mock_resp.parse.return_value = mock_completion
    mock_create.return_value = mock_resp

    rtn.with_raw_response.create = mock_create
    rtn.create.return_value = mock_completion
    return rtn

Domain

Subdomains

Frequently Asked Questions

What does mock_client() do?
mock_client() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is mock_client() defined?
mock_client() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 635.

Analyze Your Own Codebase

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

Try Supermodel Free