forked from TransformerOptimus/SuperAGI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
TransformerOptimus
committed
Jun 22, 2023
1 parent
bf0cdde
commit 3ac9699
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
from unittest.mock import Mock, create_autospec | ||
from sqlalchemy.orm import Session | ||
from superagi.models.agent_execution_feed import AgentExecutionFeed | ||
|
||
|
||
def test_get_last_tool_response(): | ||
mock_session = create_autospec(Session) | ||
agent_execution_feed_1 = AgentExecutionFeed(id=1, agent_execution_id=2, feed="Tool test1", role='system') | ||
agent_execution_feed_2 = AgentExecutionFeed(id=2, agent_execution_id=2, feed="Tool test2", role='system') | ||
|
||
mock_session.query().filter().order_by().all.return_value = [agent_execution_feed_1, agent_execution_feed_2] | ||
|
||
result = AgentExecutionFeed.get_last_tool_response(mock_session, 2) | ||
|
||
assert result == agent_execution_feed_1.feed # as agent_execution_feed_1 should be the latest based on created_at | ||
|
||
|
||
def test_get_last_tool_response_with_tool_name(): | ||
mock_session = create_autospec(Session) | ||
agent_execution_feed_1 = AgentExecutionFeed(id=1, agent_execution_id=2, feed="Tool test1", role='system') | ||
agent_execution_feed_2 = AgentExecutionFeed(id=2, agent_execution_id=2, feed="Tool test2", role='system') | ||
|
||
mock_session.query().filter().order_by().all.return_value = [agent_execution_feed_1, agent_execution_feed_2] | ||
|
||
result = AgentExecutionFeed.get_last_tool_response(mock_session, 2, "test2") | ||
assert result == agent_execution_feed_2.feed |