File size: 951 Bytes
4a86b49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# tests/test_agent_tool_selection_updated.py
import pytest
from unittest.mock import patch, Mock
from agent.agent import initialize_agent
from langchain.agents.agent import AgentExecutor

class TestAgentToolSelectionUpdated:

    @pytest.fixture(autouse=True)
    def setup_agent(self):
        with patch("streamlit.secrets", {"GOOGLE_API_KEY": "AIzaSyBxrJAxe69t02jMZKtOGXY3gCIgVm8RAMY"}):
            with patch("langchain_openai.ChatOpenAI") as mock_llm:
                mock_llm.return_value = Mock()
                self.agent = initialize_agent()

    def test_agent_has_all_tools_registered(self):
        expected = {
            "code_analysis",
            "get_revenue_variance",
            "get_gross_margin_pct",
            "get_opex_breakdown",
            "get_ebitda_proxy",
            "get_cash_runway",
            "plot_chart"
        }
        actual = {tool.name for tool in self.agent.tools}
        assert expected == actual