Home / Function/ test_default_method_implementations() — langchain Function Reference

test_default_method_implementations() — langchain Function Reference

Architecture documentation for the test_default_method_implementations() function in test_runnable.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  885a7702_d799_80c5_7111_a31c94ee5e8e["test_default_method_implementations()"]
  26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"]
  885a7702_d799_80c5_7111_a31c94ee5e8e -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5
  593bb72a_4695_6c93_b95c_e277aca006ae["batch()"]
  885a7702_d799_80c5_7111_a31c94ee5e8e -->|calls| 593bb72a_4695_6c93_b95c_e277aca006ae
  fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"]
  885a7702_d799_80c5_7111_a31c94ee5e8e -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4
  style 885a7702_d799_80c5_7111_a31c94ee5e8e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable.py lines 1377–1417

def test_default_method_implementations(mocker: MockerFixture) -> None:
    fake = FakeRunnable()
    spy = mocker.spy(fake, "invoke")

    assert fake.invoke("hello", {"tags": ["a-tag"]}) == 5
    assert spy.call_args_list == [
        mocker.call("hello", {"tags": ["a-tag"]}),
    ]
    spy.reset_mock()

    assert [*fake.stream("hello", {"metadata": {"key": "value"}})] == [5]
    assert spy.call_args_list == [
        mocker.call("hello", {"metadata": {"key": "value"}}),
    ]
    spy.reset_mock()

    assert fake.batch(
        ["hello", "wooorld"], [{"tags": ["a-tag"]}, {"metadata": {"key": "value"}}]
    ) == [5, 7]

    assert len(spy.call_args_list) == 2
    for call in spy.call_args_list:
        call_arg = call.args[0]

        if call_arg == "hello":
            assert call_arg == "hello"
            assert call.args[1].get("tags") == ["a-tag"]
            assert call.args[1].get("metadata") == {}
        else:
            assert call_arg == "wooorld"
            assert call.args[1].get("tags") == []
            assert call.args[1].get("metadata") == {"key": "value"}

    spy.reset_mock()

    assert fake.batch(["hello", "wooorld"], {"tags": ["a-tag"]}) == [5, 7]
    assert len(spy.call_args_list) == 2
    assert {call.args[0] for call in spy.call_args_list} == {"hello", "wooorld"}
    for call in spy.call_args_list:
        assert call.args[1].get("tags") == ["a-tag"]
        assert call.args[1].get("metadata") == {}

Domain

Subdomains

Frequently Asked Questions

What does test_default_method_implementations() do?
test_default_method_implementations() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_default_method_implementations() defined?
test_default_method_implementations() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 1377.
What does test_default_method_implementations() call?
test_default_method_implementations() calls 2 function(s): batch, invoke.

Analyze Your Own Codebase

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

Try Supermodel Free