mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
fix test
This commit is contained in:
@@ -1606,22 +1606,30 @@ def test_agent_with_knowledge_sources():
|
|||||||
def test_agent_with_knowledge_sources_works_with_test():
|
def test_agent_with_knowledge_sources_works_with_test():
|
||||||
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)
|
||||||
agent = Agent(
|
|
||||||
role="test role",
|
|
||||||
goal="test goal",
|
|
||||||
backstory="test backstory",
|
|
||||||
llm=LLM(model="gpt-4o-mini"),
|
|
||||||
knowledge_sources=[string_source],
|
|
||||||
)
|
|
||||||
|
|
||||||
agent.create_agent_executor()
|
with patch(
|
||||||
agent_copy = agent.copy()
|
"crewai.knowledge.storage.knowledge_storage.KnowledgeStorage"
|
||||||
|
) as MockKnowledge:
|
||||||
|
mock_knowledge_instance = MockKnowledge.return_value
|
||||||
|
mock_knowledge_instance.sources = [string_source]
|
||||||
|
|
||||||
assert agent_copy.role == agent.role
|
agent = Agent(
|
||||||
assert agent_copy.goal == agent.goal
|
role="test role",
|
||||||
assert agent_copy.backstory == agent.backstory
|
goal="test goal",
|
||||||
assert agent_copy.knowledge_sources == agent.knowledge_sources
|
backstory="test backstory",
|
||||||
assert isinstance(agent_copy.llm, LLM)
|
llm=LLM(model="gpt-4o-mini"),
|
||||||
|
knowledge_sources=[string_source],
|
||||||
|
)
|
||||||
|
|
||||||
|
agent.create_agent_executor()
|
||||||
|
agent_copy = agent.copy()
|
||||||
|
|
||||||
|
# Test that all properties were copied correctly
|
||||||
|
assert agent_copy.role == agent.role
|
||||||
|
assert agent_copy.goal == agent.goal
|
||||||
|
assert agent_copy.backstory == agent.backstory
|
||||||
|
assert agent_copy.knowledge_sources == agent.knowledge_sources
|
||||||
|
assert isinstance(agent_copy.llm, LLM)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
|
|||||||
Reference in New Issue
Block a user