mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 08:12:39 +00:00
fixed test
This commit is contained in:
@@ -1602,28 +1602,24 @@ def test_agent_with_knowledge_sources():
|
|||||||
assert "red" in result.raw.lower()
|
assert "red" in result.raw.lower()
|
||||||
|
|
||||||
|
|
||||||
def test_agent_with_knowledge_sources_works_with_test():
|
@patch("crewai.knowledge.storage.knowledge_storage.KnowledgeStorage")
|
||||||
|
def test_agent_with_knowledge_sources_works_with_copy(
|
||||||
|
MockKnowledgeStorage,
|
||||||
|
):
|
||||||
content = "Brandon's favorite color is red and he likes Mexican food."
|
content = "Brandon's favorite color is red and he likes Mexican food."
|
||||||
string_source = StringKnowledgeSource(content=content)
|
string_source = StringKnowledgeSource(content=content)
|
||||||
|
mock_knowledge_instance = MockKnowledgeStorage.return_value
|
||||||
with patch(
|
|
||||||
"crewai.knowledge.storage.knowledge_storage.KnowledgeStorage"
|
|
||||||
) as MockKnowledge:
|
|
||||||
mock_knowledge_instance = MockKnowledge.return_value
|
|
||||||
mock_knowledge_instance.sources = [string_source]
|
mock_knowledge_instance.sources = [string_source]
|
||||||
|
mock_knowledge_instance.query.return_value = [{"content": content}]
|
||||||
|
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
role="test role",
|
role="Information Agent",
|
||||||
goal="test goal",
|
goal="Provide information based on knowledge sources",
|
||||||
backstory="test backstory",
|
backstory="You have access to specific knowledge sources.",
|
||||||
llm=LLM(model="gpt-4o-mini"),
|
|
||||||
knowledge_sources=[string_source],
|
knowledge_sources=[string_source],
|
||||||
)
|
)
|
||||||
|
|
||||||
agent.create_agent_executor()
|
|
||||||
agent_copy = agent.copy()
|
agent_copy = agent.copy()
|
||||||
|
|
||||||
# Test that all properties were copied correctly
|
|
||||||
assert agent_copy.role == agent.role
|
assert agent_copy.role == agent.role
|
||||||
assert agent_copy.goal == agent.goal
|
assert agent_copy.goal == agent.goal
|
||||||
assert agent_copy.backstory == agent.backstory
|
assert agent_copy.backstory == agent.backstory
|
||||||
|
|||||||
Reference in New Issue
Block a user