Skip to content

Commit

Permalink
Fix broken test from agent import change
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaC215 committed Aug 9, 2024
1 parent 57889bd commit b6152f8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions service/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@

client = TestClient(app)

@patch("service.service.construct_agent")
def test_invoke(mock_construct_agent):
agent = mock_construct_agent.return_value
@patch("service.service.research_assistant")
def test_invoke(mock_agent):
QUESTION = "What is the weather in Tokyo?"
ANSWER = "The weather in Tokyo is 70 degrees."
agent_response = {"messages": [AIMessage(content=ANSWER)]}
agent.ainvoke = AsyncMock(return_value=agent_response)
mock_agent.ainvoke = AsyncMock(return_value=agent_response)

with client as c:
response = c.post("/invoke", json={"message": QUESTION})
assert response.status_code == 200

agent.ainvoke.assert_awaited_once()
input_message = agent.ainvoke.await_args.kwargs["input"]["messages"][0]
mock_agent.ainvoke.assert_awaited_once()
input_message = mock_agent.ainvoke.await_args.kwargs["input"]["messages"][0]
assert input_message.content == QUESTION

output = ChatMessage.parse_obj(response.json())
Expand Down

0 comments on commit b6152f8

Please sign in to comment.