@@ -769,6 +769,17 @@ def test_list(self, mock_client: Mock) -> None:
769769 page = SimpleNamespace (agents = [agent_view_1 , agent_view_2 , agent_view_3 ])
770770 mock_client .agents .list .return_value = page
771771
772+ # Mock retrieve to return the corresponding agent_view when called
773+ def mock_retrieve (agent_id : str , ** _kwargs : object ) -> MockAgentView :
774+ agent_views = {
775+ "agent_001" : agent_view_1 ,
776+ "agent_002" : agent_view_2 ,
777+ "agent_003" : agent_view_3 ,
778+ }
779+ return agent_views [agent_id ]
780+
781+ mock_client .agents .retrieve .side_effect = mock_retrieve
782+
772783 client = AgentOps (mock_client )
773784 agents = client .list (
774785 limit = 10 ,
@@ -784,32 +795,32 @@ def test_list(self, mock_client: Mock) -> None:
784795 assert agents [1 ].id == "agent_002"
785796 assert agents [2 ].id == "agent_003"
786797
787- # Test that get_info() retrieves the cached AgentView for the first agent
798+ # Test that get_info() retrieves the AgentView for the first agent
788799 info = agents [0 ].get_info ()
789800 assert info .id == "agent_001"
790801 assert info .name == "first-agent"
791802 assert info .create_time_ms == 1234567890000
792803 assert info .is_public is False
793804 assert info .source is None
794805
795- # Test that get_info() retrieves the cached AgentView for the second agent
806+ # Test that get_info() retrieves the AgentView for the second agent
796807 info = agents [1 ].get_info ()
797808 assert info .id == "agent_002"
798809 assert info .name == "second-agent"
799810 assert info .create_time_ms == 1234567891000
800811 assert info .is_public is True
801812 assert info .source == {"type" : "git" , "git" : {"repository" : "https://github.com/example/repo" }}
802813
803- # Test that get_info() retrieves the cached AgentView for the third agent
814+ # Test that get_info() retrieves the AgentView for the third agent
804815 info = agents [2 ].get_info ()
805816 assert info .id == "agent_003"
806817 assert info .name == "third-agent"
807818 assert info .create_time_ms == 1234567892000
808819 assert info .is_public is False
809820 assert info .source == {"type" : "npm" , "npm" : {"package_name" : "example-package" }}
810821
811- # Verify that agents.retrieve was NOT called (because we're using cached data)
812- mock_client .agents .retrieve .assert_not_called ()
822+ # Verify that agents.retrieve was called for each agent
823+ assert mock_client .agents .retrieve .call_count == 3
813824
814825 mock_client .agents .list .assert_called_once ()
815826
0 commit comments