@@ -499,9 +499,32 @@ def test_from_id(self, mock_client: Mock) -> None:
499499 assert isinstance (agent , Agent )
500500 assert agent .id == "agent_123"
501501
502- def test_list (self , mock_client : Mock , agent_view : MockAgentView ) -> None :
502+ def test_list (self , mock_client : Mock ) -> None :
503503 """Test list method."""
504- page = SimpleNamespace (agents = [agent_view ])
504+ # Create three agent views with different data
505+ agent_view_1 = MockAgentView (
506+ id = "agent_001" ,
507+ name = "first-agent" ,
508+ create_time_ms = 1234567890000 ,
509+ is_public = False ,
510+ source = None ,
511+ )
512+ agent_view_2 = MockAgentView (
513+ id = "agent_002" ,
514+ name = "second-agent" ,
515+ create_time_ms = 1234567891000 ,
516+ is_public = True ,
517+ source = {"type" : "git" , "git" : {"repository" : "https://github.com/example/repo" }},
518+ )
519+ agent_view_3 = MockAgentView (
520+ id = "agent_003" ,
521+ name = "third-agent" ,
522+ create_time_ms = 1234567892000 ,
523+ is_public = False ,
524+ source = {"type" : "npm" , "npm" : {"package_name" : "example-package" }},
525+ )
526+
527+ page = SimpleNamespace (agents = [agent_view_1 , agent_view_2 , agent_view_3 ])
505528 mock_client .agents .list .return_value = page
506529
507530 client = AgentOps (mock_client )
@@ -510,9 +533,42 @@ def test_list(self, mock_client: Mock, agent_view: MockAgentView) -> None:
510533 starting_after = "agent_000" ,
511534 )
512535
513- assert len (agents ) == 1
514- assert isinstance (agents [0 ], Agent )
515- assert agents [0 ].id == "agent_123"
536+ # Verify we got three agents
537+ assert len (agents ) == 3
538+ assert all (isinstance (agent , Agent ) for agent in agents )
539+
540+ # Verify the agent IDs
541+ assert agents [0 ].id == "agent_001"
542+ assert agents [1 ].id == "agent_002"
543+ assert agents [2 ].id == "agent_003"
544+
545+ # Test that get_info() retrieves the cached AgentView for the first agent
546+ info = agents [0 ].get_info ()
547+ assert info .id == "agent_001"
548+ assert info .name == "first-agent"
549+ assert info .create_time_ms == 1234567890000
550+ assert info .is_public is False
551+ assert info .source is None
552+
553+ # Test that get_info() retrieves the cached AgentView for the second agent
554+ info = agents [1 ].get_info ()
555+ assert info .id == "agent_002"
556+ assert info .name == "second-agent"
557+ assert info .create_time_ms == 1234567891000
558+ assert info .is_public is True
559+ assert info .source == {"type" : "git" , "git" : {"repository" : "https://github.com/example/repo" }}
560+
561+ # Test that get_info() retrieves the cached AgentView for the third agent
562+ info = agents [2 ].get_info ()
563+ assert info .id == "agent_003"
564+ assert info .name == "third-agent"
565+ assert info .create_time_ms == 1234567892000
566+ assert info .is_public is False
567+ assert info .source == {"type" : "npm" , "npm" : {"package_name" : "example-package" }}
568+
569+ # Verify that agents.retrieve was NOT called (because we're using cached data)
570+ mock_client .agents .retrieve .assert_not_called ()
571+
516572 mock_client .agents .list .assert_called_once ()
517573
518574
0 commit comments