🌐 AI搜索 & 代理 主页
Skip to content

Commit 0f28c93

Browse files
committed
[FastAPI] Directory structure change for test code
1 parent 56c8dd7 commit 0f28c93

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/fastAPI/tests/test_main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
import aiohttp
3+
import sys
4+
import os
5+
# Add the project directory to the system path
6+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'app')))
7+
from fastapi.testclient import TestClient
8+
from main import app # Import the app from app/main.py
9+
10+
client = TestClient(app)
11+
12+
@pytest.mark.asyncio
13+
async def test_fetch_builds():
14+
async with aiohttp.ClientSession() as session:
15+
response = client.get("/builds/")
16+
assert response.status_code == 200
17+
data = response.json()
18+
assert "dashboard_urls" in data
19+
assert isinstance(data["dashboard_urls"], list)
20+
21+
@pytest.mark.asyncio
22+
async def test_fetch_sessions():
23+
async with aiohttp.ClientSession() as session:
24+
response = client.get("/sessions/")
25+
assert response.status_code == 200
26+
data = response.json()
27+
assert "session_names" in data
28+
assert isinstance(data["session_names"], list)
29+

0 commit comments

Comments
 (0)