|
14 | 14 | MockScorerView, |
15 | 15 | MockSnapshotView, |
16 | 16 | MockBlueprintView, |
| 17 | + MockAgentView, |
17 | 18 | create_mock_httpx_response, |
18 | 19 | ) |
19 | | -from runloop_api_client.sdk import Devbox, Scorer, Snapshot, Blueprint, StorageObject |
| 20 | +from runloop_api_client.sdk import Agent, Devbox, Scorer, Snapshot, Blueprint, StorageObject |
20 | 21 | from runloop_api_client.sdk.sync import ( |
21 | 22 | DevboxOps, |
22 | 23 | ScorerOps, |
23 | 24 | RunloopSDK, |
24 | 25 | SnapshotOps, |
25 | 26 | BlueprintOps, |
26 | 27 | StorageObjectOps, |
| 28 | + AgentOps, |
27 | 29 | ) |
28 | 30 | from runloop_api_client.lib.polling import PollingConfig |
29 | 31 |
|
@@ -653,13 +655,56 @@ def test_list_multiple(self, mock_client: Mock) -> None: |
653 | 655 | mock_client.scenarios.scorers.list.assert_called_once() |
654 | 656 |
|
655 | 657 |
|
| 658 | +class TestAgentClient: |
| 659 | + """Tests for AgentClient class.""" |
| 660 | + |
| 661 | + def test_create(self, mock_client: Mock, agent_view: MockAgentView) -> None: |
| 662 | + """Test create method.""" |
| 663 | + mock_client.agents.create.return_value = agent_view |
| 664 | + |
| 665 | + client = AgentOps(mock_client) |
| 666 | + agent = client.create( |
| 667 | + name="test-agent", |
| 668 | + metadata={"key": "value"}, |
| 669 | + ) |
| 670 | + |
| 671 | + assert isinstance(agent, Agent) |
| 672 | + assert agent.id == "agent_123" |
| 673 | + mock_client.agents.create.assert_called_once() |
| 674 | + |
| 675 | + def test_from_id(self, mock_client: Mock) -> None: |
| 676 | + """Test from_id method.""" |
| 677 | + client = AgentOps(mock_client) |
| 678 | + agent = client.from_id("agent_123") |
| 679 | + |
| 680 | + assert isinstance(agent, Agent) |
| 681 | + assert agent.id == "agent_123" |
| 682 | + |
| 683 | + def test_list(self, mock_client: Mock, agent_view: MockAgentView) -> None: |
| 684 | + """Test list method.""" |
| 685 | + page = SimpleNamespace(agents=[agent_view]) |
| 686 | + mock_client.agents.list.return_value = page |
| 687 | + |
| 688 | + client = AgentOps(mock_client) |
| 689 | + agents = client.list( |
| 690 | + limit=10, |
| 691 | + starting_after="agent_000", |
| 692 | + ) |
| 693 | + |
| 694 | + assert len(agents) == 1 |
| 695 | + assert isinstance(agents[0], Agent) |
| 696 | + assert agents[0].id == "agent_123" |
| 697 | + mock_client.agents.list.assert_called_once() |
| 698 | + |
| 699 | + |
656 | 700 | class TestRunloopSDK: |
657 | 701 | """Tests for RunloopSDK class.""" |
658 | 702 |
|
659 | 703 | def test_init(self) -> None: |
660 | 704 | """Test RunloopSDK initialization.""" |
661 | 705 | sdk = RunloopSDK(bearer_token="test-token") |
662 | 706 | assert sdk.api is not None |
| 707 | + assert isinstance(sdk.agent, AgentOps) |
663 | 708 | assert isinstance(sdk.devbox, DevboxOps) |
664 | 709 | assert isinstance(sdk.scorer, ScorerOps) |
665 | 710 | assert isinstance(sdk.snapshot, SnapshotOps) |
|
0 commit comments