2024-06-22 14:50:32 -04:00
|
|
|
import pytest
|
|
|
|
from pytest_mock import MockerFixture
|
2024-08-02 11:02:45 -04:00
|
|
|
from agnext.core import AgentRuntime, AgentInstantiationContext, AgentId
|
2024-06-22 14:50:32 -04:00
|
|
|
|
|
|
|
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
|
2024-08-02 11:02:45 -04:00
|
|
|
with AgentInstantiationContext.populate_context((runtime, AgentId("name", "namespace"))):
|
|
|
|
agent = NoopAgent()
|
|
|
|
assert agent.runtime == runtime
|
|
|
|
assert agent.id == AgentId("name", "namespace")
|
2024-06-22 14:50:32 -04:00
|
|
|
|