Spaces:
Sleeping
Sleeping
File size: 1,192 Bytes
bf6dbfa 0643073 bf6dbfa 0643073 bf6dbfa 0643073 bf6dbfa | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import pytest
from agent.nodes import execute_tool
from agent.state import AgentState
def test_tool_execution_missing_fields(mocker):
mock_tool = mocker.patch('agent.nodes.mock_lead_capture')
state = AgentState(
conversation_history=[],
current_message="",
detected_intent="HIGH_INTENT_LEAD",
retrieved_documents=[],
user_name="Alex",
user_email="alex@email.com",
creator_platform=None,
lead_ready=True,
response=""
)
result = execute_tool(state)
mock_tool.assert_not_called()
assert "Error" in result["response"]
def test_tool_execution_all_fields(mocker):
mock_tool = mocker.patch('agent.nodes.mock_lead_capture')
state = AgentState(
conversation_history=[],
current_message="",
detected_intent="HIGH_INTENT_LEAD",
retrieved_documents=[],
user_name="Alex",
user_email="alex@email.com",
creator_platform="YouTube",
lead_ready=True,
response=""
)
result = execute_tool(state)
mock_tool.assert_called_once_with("Alex", "alex@email.com", "YouTube")
assert "Thanks Alex" in result["response"]
|