feat: orchestrator MVP — webhooks, agent launcher, QG checks
This commit is contained in:
65
tests/test_webhooks.py
Normal file
65
tests/test_webhooks.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
# Override DB path before importing app
|
||||
os.environ["ORCH_DB_PATH"] = os.path.join(tempfile.gettempdir(), "test_orchestrator.db")
|
||||
|
||||
from src.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_health():
|
||||
resp = client.get("/health")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "ok"
|
||||
assert resp.json()["service"] == "orchestrator"
|
||||
|
||||
|
||||
def test_plane_webhook_accepts():
|
||||
resp = client.post("/webhook/plane", json={
|
||||
"event": "work_item.created",
|
||||
"data": {"id": "test-123", "name": "Test task", "project": "proj-1"}
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "accepted"
|
||||
|
||||
|
||||
def test_plane_webhook_comment():
|
||||
resp = client.post("/webhook/plane", json={
|
||||
"event": "comment.created",
|
||||
"data": {"comment": "LGTM :approved:"}
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "accepted"
|
||||
|
||||
|
||||
def test_gitea_webhook_push():
|
||||
resp = client.post(
|
||||
"/webhook/gitea",
|
||||
json={"ref": "refs/heads/feature/test", "repository": {"name": "enduro-trails"}},
|
||||
headers={"X-Gitea-Event": "push"}
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "accepted"
|
||||
|
||||
|
||||
def test_gitea_webhook_pr():
|
||||
resp = client.post(
|
||||
"/webhook/gitea",
|
||||
json={
|
||||
"action": "reviewed",
|
||||
"pull_request": {"state": "approved", "number": 1}
|
||||
},
|
||||
headers={"X-Gitea-Event": "pull_request"}
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "accepted"
|
||||
|
||||
|
||||
def test_status_endpoint():
|
||||
resp = client.get("/status")
|
||||
assert resp.status_code == 200
|
||||
assert "active_tasks" in resp.json()
|
||||
Reference in New Issue
Block a user