|
13 | 13 | MockObjectView, |
14 | 14 | MockSnapshotView, |
15 | 15 | MockBlueprintView, |
| 16 | + MockAgentView, |
16 | 17 | create_mock_httpx_response, |
17 | 18 | ) |
18 | | -from runloop_api_client.sdk import Devbox, Snapshot, Blueprint, StorageObject |
| 19 | +from runloop_api_client.sdk import Devbox, Snapshot, Blueprint, StorageObject, Agent |
19 | 20 | from runloop_api_client.sdk.sync import ( |
20 | 21 | DevboxOps, |
21 | 22 | RunloopSDK, |
22 | 23 | SnapshotOps, |
23 | 24 | BlueprintOps, |
24 | 25 | StorageObjectOps, |
| 26 | + AgentOps, |
25 | 27 | ) |
26 | 28 | from runloop_api_client.lib.polling import PollingConfig |
27 | 29 |
|
@@ -472,13 +474,56 @@ def test_upload_from_dir_with_string_path( |
472 | 474 | mock_client.objects.complete.assert_called_once() |
473 | 475 |
|
474 | 476 |
|
| 477 | +class TestAgentClient: |
| 478 | + """Tests for AgentClient class.""" |
| 479 | + |
| 480 | + def test_create(self, mock_client: Mock, agent_view: MockAgentView) -> None: |
| 481 | + """Test create method.""" |
| 482 | + mock_client.agents.create.return_value = agent_view |
| 483 | + |
| 484 | + client = AgentOps(mock_client) |
| 485 | + agent = client.create( |
| 486 | + name="test-agent", |
| 487 | + metadata={"key": "value"}, |
| 488 | + ) |
| 489 | + |
| 490 | + assert isinstance(agent, Agent) |
| 491 | + assert agent.id == "agent_123" |
| 492 | + mock_client.agents.create.assert_called_once() |
| 493 | + |
| 494 | + def test_from_id(self, mock_client: Mock) -> None: |
| 495 | + """Test from_id method.""" |
| 496 | + client = AgentOps(mock_client) |
| 497 | + agent = client.from_id("agent_123") |
| 498 | + |
| 499 | + assert isinstance(agent, Agent) |
| 500 | + assert agent.id == "agent_123" |
| 501 | + |
| 502 | + def test_list(self, mock_client: Mock, agent_view: MockAgentView) -> None: |
| 503 | + """Test list method.""" |
| 504 | + page = SimpleNamespace(agents=[agent_view]) |
| 505 | + mock_client.agents.list.return_value = page |
| 506 | + |
| 507 | + client = AgentOps(mock_client) |
| 508 | + agents = client.list( |
| 509 | + limit=10, |
| 510 | + starting_after="agent_000", |
| 511 | + ) |
| 512 | + |
| 513 | + assert len(agents) == 1 |
| 514 | + assert isinstance(agents[0], Agent) |
| 515 | + assert agents[0].id == "agent_123" |
| 516 | + mock_client.agents.list.assert_called_once() |
| 517 | + |
| 518 | + |
475 | 519 | class TestRunloopSDK: |
476 | 520 | """Tests for RunloopSDK class.""" |
477 | 521 |
|
478 | 522 | def test_init(self) -> None: |
479 | 523 | """Test RunloopSDK initialization.""" |
480 | 524 | sdk = RunloopSDK(bearer_token="test-token") |
481 | 525 | assert sdk.api is not None |
| 526 | + assert isinstance(sdk.agent, AgentOps) |
482 | 527 | assert isinstance(sdk.devbox, DevboxOps) |
483 | 528 | assert isinstance(sdk.snapshot, SnapshotOps) |
484 | 529 | assert isinstance(sdk.blueprint, BlueprintOps) |
|
0 commit comments