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
1 parent
488d4fa
commit b6d82ea
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
tests/unit_tests/controllers/test_agent_execution_config.py
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,42 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from main import app | ||
from superagi.models.agent_execution_config import AgentExecutionConfiguration | ||
|
||
client = TestClient(app) | ||
|
||
|
||
@pytest.fixture | ||
def mocks(): | ||
# Mock tool kit data for testing | ||
mock_execution_config = AgentExecutionConfiguration(id=1, key="test_key", value="['test']") | ||
return mock_execution_config | ||
|
||
|
||
def test_get_agent_execution_configuration_success(mocks): | ||
# Mock the database session and query functions | ||
with patch('superagi.helper.auth.get_user_organisation') as mock_get_user_org, \ | ||
patch('superagi.controllers.agent_execution_config.db') as mock_db: | ||
|
||
mock_execution_config = mocks | ||
mock_db.session.query.return_value.filter.return_value.all.return_value = [mock_execution_config] | ||
|
||
response = client.get("/agent_executions_configs/details/1") | ||
|
||
assert response.status_code == 200 | ||
assert response.json() == {"test_key": ['test']} | ||
|
||
|
||
def test_get_agent_execution_configuration_not_found(): | ||
with patch('main.check_auth') as mock_check_auth: | ||
with patch('main.db') as mock_db: | ||
mock_check_auth.return_value = True | ||
mock_db.session.query.return_value.filter.return_value.all.return_value = [] | ||
|
||
response = client.get("/agent_executions_configs/details/1") | ||
|
||
assert response.status_code == 404 | ||
assert response.json() == {"detail": "Agent Execution Configuration not found"} |