test: isolate webhook tests from live Plane API (fix CI)
This commit is contained in:
@@ -54,13 +54,19 @@ def test_status_endpoint():
|
||||
assert "active_tasks" in resp.json()
|
||||
|
||||
|
||||
@patch("src.plane_sync.add_comment")
|
||||
@patch("src.plane_sync.fetch_issue_sequence_id", return_value=None)
|
||||
@patch("src.plane_sync.fetch_issue_fields", return_value=("Test task", "This is a detailed test description for the task"))
|
||||
@patch("src.webhooks.plane._create_gitea_branch", new_callable=AsyncMock)
|
||||
@patch("src.webhooks.plane._create_initial_docs", new_callable=AsyncMock)
|
||||
def test_plane_webhook_creates_task(mock_docs, mock_branch):
|
||||
"""work_item.created → task in DB with stage=analysis."""
|
||||
def test_plane_webhook_creates_task(mock_docs, mock_branch, mock_fetch_fields, mock_fetch_seq, mock_add_comment):
|
||||
"""work_item.created (via In Progress status) → task in DB with stage=analysis."""
|
||||
resp = client.post("/webhook/plane", json={
|
||||
"event": "work_item.created",
|
||||
"data": {"id": "test-123", "name": "Test task", "project": "proj-1"}
|
||||
"event": "issue", "action": "updated",
|
||||
"data": {
|
||||
"id": "test-123", "name": "Test task", "project": "proj-1",
|
||||
"state": {"id": "b873d9eb-993c-48cd-97ac-99a9b1623967", "name": "In Progress", "group": "started"},
|
||||
}
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["status"] == "accepted"
|
||||
@@ -202,8 +208,9 @@ def test_gitea_webhook_push():
|
||||
assert resp.json()["status"] == "accepted"
|
||||
|
||||
|
||||
@patch("src.webhooks.gitea.plane_notify_stage")
|
||||
@patch("src.webhooks.gitea.launcher")
|
||||
def test_gitea_push_with_adr_advances_stage(mock_launcher):
|
||||
def test_gitea_push_with_adr_advances_stage(mock_launcher, mock_plane_notify):
|
||||
"""Push with ADR files at architecture stage → advance to development."""
|
||||
mock_launcher.launch.return_value = 1
|
||||
|
||||
@@ -235,7 +242,7 @@ def test_gitea_push_with_adr_advances_stage(mock_launcher):
|
||||
task = conn.execute("SELECT * FROM tasks WHERE plane_id = 'push-001'").fetchone()
|
||||
conn.close()
|
||||
assert task["stage"] == "development"
|
||||
mock_launcher.launch.assert_called_once()
|
||||
mock_plane_notify.assert_called_once()
|
||||
|
||||
|
||||
@patch("src.webhooks.gitea.check_ci_green")
|
||||
|
||||
Reference in New Issue
Block a user