File size: 1,042 Bytes
6401851
 
 
 
 
 
 
 
 
 
 
254d18e
6401851
 
254d18e
6401851
 
 
 
 
 
254d18e
6401851
 
 
 
 
254d18e
6401851
 
 
 
 
 
 
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
import requests
import time
import subprocess
import os

def test_api_endpoints():
    print("Starting application in background...")
    env = os.environ.copy()
    env["GITHUB_TOKEN"] = "mock_token"
    # Run app.py in background
    process = subprocess.Popen(["python3", "app.py"], env=env)

    # Wait for startup
    time.sleep(10)

    try:
        print("Testing /health endpoint...")
        res = requests.get("http://localhost:7860/health")
        print(f"Status: {res.status_code}, Body: {res.json()}")
        assert res.status_code == 200
        assert res.json()["status"] == "ok"

        print("Testing /api/info endpoint...")
        res = requests.get("http://localhost:7860/api/info")
        print(f"Status: {res.status_code}, Body: {res.json()}")
        assert res.status_code == 200
        assert "UX Analysis Orchestrator" in res.json()["app"]

        print("API tests PASSED!")
    finally:
        print("Killing application...")
        process.terminate()

if __name__ == "__main__":
    test_api_endpoints()