mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-15 17:25:04 -05:00
* Added listing, sorting, filtering and ordering of agents * feat(market): general upkeep for vscode and small docs * feat(market): most of search * fix(market): hinting on the sort was weird + linting * feat(market): migrations and schema updates * lint(market): autolint * feat(market): better search * feat(market): file download * feat(market): analytics of downloads * Added tracking of views * changed all imports to be fully qualified * Upgrade sentry sdk * Added an admin endpoint to submit new agents * fixes * Added endpoint that just tracks download * Starting adding the marketplace page * Marketplace client * Create template of the marketplace page * Updated client * fix(market): debug port * feat(market): agents by downloads * fix(market, builder): hook up frontend and backend * feat(builder, market): build a "better" market page that loads data * feat(builder): updated search (working) and page (kinda working) * feat(builder): add a feature agents ui (not backed yet) * feat(builder): improve detail page content * Added run script * Added pre populate database command * Add AnalyticsTracker on create agent * Add download counts for top agents * Add hb page prometheus metrics * Added featured agents funcitonality * renamed endpoint to health * Adding download flow * normalised api routes * update readme * feat(market) : default featured * formatting * revert changes to autogpt and forge * Updated Readme * Eerror when creating an agent from a template installed from (#7697) fix creating graph from template * Add dockerfile * z level fix * Updated env vars * updated populate url * formatting * fixed linting error * Set defaults * Allow only next.js dev server * fixed url * removed graph reassignment as due to change in master --------- Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
80 lines
2.1 KiB
Python
80 lines
2.1 KiB
Python
from datetime import datetime, timezone
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from market.app import app
|
|
from market.db import AgentQueryError
|
|
|
|
|
|
@pytest.fixture
|
|
def test_client():
|
|
return TestClient(app)
|
|
|
|
|
|
# Mock data
|
|
mock_agents = [
|
|
{
|
|
"id": "1",
|
|
"name": "Agent 1",
|
|
"description": "Description 1",
|
|
"author": "Author 1",
|
|
"keywords": ["AI", "chatbot"],
|
|
"categories": ["general"],
|
|
"version": 1,
|
|
"createdAt": datetime.now(timezone.utc),
|
|
"updatedAt": datetime.now(timezone.utc),
|
|
"graph": {"node1": "value1"},
|
|
},
|
|
{
|
|
"id": "2",
|
|
"name": "Agent 2",
|
|
"description": "Description 2",
|
|
"author": "Author 2",
|
|
"keywords": ["ML", "NLP"],
|
|
"categories": ["specialized"],
|
|
"version": 1,
|
|
"createdAt": datetime.now(timezone.utc),
|
|
"updatedAt": datetime.now(timezone.utc),
|
|
"graph": {"node2": "value2"},
|
|
},
|
|
]
|
|
|
|
|
|
# TODO: Need to mock prisma somehow
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_agents(test_client):
|
|
response = test_client.get("/agents")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert len(data["agents"]) == 2
|
|
assert data["total_count"] == 2
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_agents_with_filters(test_client):
|
|
response = await test_client.get("/agents?name=Agent 1&keyword=AI&category=general")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert len(data["agents"]) == 1
|
|
assert data["agents"][0]["name"] == "Agent 1"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_agent_details(test_client, mock_get_agent_details):
|
|
response = await test_client.get("/agents/1")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["id"] == "1"
|
|
assert data["name"] == "Agent 1"
|
|
assert "graph" in data
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_nonexistent_agent(test_client, mock_get_agent_details):
|
|
mock_get_agent_details.side_effect = AgentQueryError("Agent not found")
|
|
response = await test_client.get("/agents/999")
|
|
assert response.status_code == 404
|