mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Merge branch 'main' of github.com:crewAIInc/crewAI into fix/memory-embedder-config
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from crewai_tools import BaseTool
|
from crewai_tools import BaseTool
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from crewai import Agent, Crew, Task
|
from crewai import Agent, Task
|
||||||
from crewai.tools.tool_usage import ToolUsage
|
from crewai.tools.tool_usage import ToolUsage
|
||||||
|
|
||||||
|
|
||||||
@@ -44,36 +44,12 @@ example_task = Task(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_random_number_tool_usage():
|
|
||||||
crew = Crew(
|
|
||||||
agents=[example_agent],
|
|
||||||
tasks=[example_task],
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch.object(random, "randint", return_value=42):
|
|
||||||
result = crew.kickoff()
|
|
||||||
|
|
||||||
assert "42" in result.raw
|
|
||||||
|
|
||||||
|
|
||||||
def test_random_number_tool_range():
|
def test_random_number_tool_range():
|
||||||
tool = RandomNumberTool()
|
tool = RandomNumberTool()
|
||||||
result = tool._run(1, 10)
|
result = tool._run(1, 10)
|
||||||
assert 1 <= result <= 10
|
assert 1 <= result <= 10
|
||||||
|
|
||||||
|
|
||||||
def test_random_number_tool_with_crew():
|
|
||||||
crew = Crew(
|
|
||||||
agents=[example_agent],
|
|
||||||
tasks=[example_task],
|
|
||||||
)
|
|
||||||
|
|
||||||
result = crew.kickoff()
|
|
||||||
|
|
||||||
# Check if the result contains a number between 1 and 100
|
|
||||||
assert any(str(num) in result.raw for num in range(1, 101))
|
|
||||||
|
|
||||||
|
|
||||||
def test_random_number_tool_invalid_range():
|
def test_random_number_tool_invalid_range():
|
||||||
tool = RandomNumberTool()
|
tool = RandomNumberTool()
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
|
|||||||
Reference in New Issue
Block a user