autogen/python/tests/test_base_agent.py
Jack Gerrits 1f9d5177d3 Instantiation context refactor (#293)
* WIP refactor instantiation context

* finish up changes

* Update python/src/agnext/core/_agent_runtime.py

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* Update python/src/agnext/core/_agent_runtime.py

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>

* add warning

---------

Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-08-02 11:02:45 -04:00

19 lines
594 B
Python

import pytest
from pytest_mock import MockerFixture
from agnext.core import AgentRuntime, AgentInstantiationContext, AgentId
from test_utils import NoopAgent
@pytest.mark.asyncio
async def test_base_agent_create(mocker: MockerFixture) -> None:
runtime = mocker.Mock(spec=AgentRuntime)
# Shows how to set the context for the agent instantiation in a test context
with AgentInstantiationContext.populate_context((runtime, AgentId("name", "namespace"))):
agent = NoopAgent()
assert agent.runtime == runtime
assert agent.id == AgentId("name", "namespace")