Home / Function/ test_ainvoke_uses_async_response_completed() — langchain Function Reference

test_ainvoke_uses_async_response_completed() — langchain Function Reference

Architecture documentation for the test_ainvoke_uses_async_response_completed() function in test_openai_assistant.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  858ed617_d09e_b379_a6db_e444d513e6a4["test_ainvoke_uses_async_response_completed()"]
  d76760d8_a189_0f15_aae7_cb699a67e504["test_openai_assistant.py"]
  858ed617_d09e_b379_a6db_e444d513e6a4 -->|defined in| d76760d8_a189_0f15_aae7_cb699a67e504
  81b2f5ba_63b7_1435_a3d4_96c06a47805c["_create_mock_client()"]
  858ed617_d09e_b379_a6db_e444d513e6a4 -->|calls| 81b2f5ba_63b7_1435_a3d4_96c06a47805c
  style 858ed617_d09e_b379_a6db_e444d513e6a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/agents/test_openai_assistant.py lines 56–90

async def test_ainvoke_uses_async_response_completed() -> None:
    # Arrange a runner with mocked async client and a completed run
    assistant = OpenAIAssistantRunnable(
        assistant_id="assistant_id",
        client=_create_mock_client(),
        async_client=_create_mock_client(use_async=True),
        as_agent=False,
    )
    mock_run = MagicMock()
    mock_run.id = "run-id"
    mock_run.thread_id = "thread-id"
    mock_run.status = "completed"

    # await_for_run returns a completed run
    await_for_run_mock = AsyncMock(return_value=mock_run)
    # async messages list returns messages belonging to run
    msg = MagicMock()
    msg.run_id = "run-id"
    msg.content = []
    list_mock = AsyncMock(return_value=[msg])

    with (
        patch.object(assistant, "_await_for_run", await_for_run_mock),
        patch.object(
            assistant.async_client.beta.threads.messages,
            "list",
            list_mock,
        ),
    ):
        # Act
        result = await assistant.ainvoke({"content": "hi"})

    # Assert: returns messages list (non-agent path) and did not block
    assert isinstance(result, list)
    list_mock.assert_awaited()

Domain

Subdomains

Frequently Asked Questions

What does test_ainvoke_uses_async_response_completed() do?
test_ainvoke_uses_async_response_completed() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/agents/test_openai_assistant.py.
Where is test_ainvoke_uses_async_response_completed() defined?
test_ainvoke_uses_async_response_completed() is defined in libs/langchain/tests/unit_tests/agents/test_openai_assistant.py at line 56.
What does test_ainvoke_uses_async_response_completed() call?
test_ainvoke_uses_async_response_completed() calls 1 function(s): _create_mock_client.

Analyze Your Own Codebase

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

Try Supermodel Free