-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_main.py
More file actions
48 lines (38 loc) · 1.22 KB
/
test_main.py
File metadata and controls
48 lines (38 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# test_main.py
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
OWNER = "nomenarkt"
REPO = "gpt-gateway"
BRANCH = "main"
TEST_PATH = "" # root of repo
def test_root():
response = client.get("/")
assert response.status_code == 200
assert response.json()["status"] == "ok"
def test_list_files():
response = client.get(f"/list-files/?owner={OWNER}&repo={REPO}&path={TEST_PATH}&branch={BRANCH}")
assert response.status_code == 200
data = response.json()
assert isinstance(data, dict)
assert "files" in data
assert isinstance(data["files"], list)
def test_scan_repo():
payload = {
"owner": OWNER,
"repo": REPO,
"path": TEST_PATH,
"branch": BRANCH,
"depth": 1
}
response = client.post("/scan-repo/", json=payload)
assert response.status_code == 200
assert "tree" in response.json()
def test_openapi_yaml():
response = client.get("/openapi.yaml")
assert response.status_code == 200
assert "openapi" in response.text
def test_plugin_manifest():
response = client.get("/.well-known/ai-plugin.json")
assert response.status_code == 200
assert response.json()["name_for_human"] == "GPT Gateway"