test: isolate webhook tests from live Plane API (fix CI) #27

Merged
admin merged 3 commits from fix/isolate-webhook-tests-from-plane into main 2026-06-05 07:29:05 +03:00
Owner

Summary

3 tests in tests/test_webhooks.py were hitting live Plane API in CI (clean env, no .env → Connection refused). This PR adds missing @patch decorators to isolate them.

Changes (tests/test_webhooks.py only)

  1. test_plane_webhook_creates_task: Added mocks for src.plane_sync.fetch_issue_fields, src.plane_sync.fetch_issue_sequence_id, src.plane_sync.add_comment. Also corrected the trigger event from work_item.created to issue.updated+InProgress to match the current pipeline flow (work_item.created no longer starts the pipeline — Feature 1).

  2. test_gitea_push_with_adr_advances_stage: Added @patch("src.webhooks.gitea.plane_notify_stage") to isolate the Plane stage notification call. Fixed mock_launcher.launch.assert_called_once()mock_plane_notify.assert_called_once() (code now uses enqueue_job, not launcher.launch directly).

  3. test_gitea_ci_failure_on_development_notifies_qg_failure: Already PASSED without changes.

Verification

  • 3 targeted tests: PASSED in clean docker env (ro mount, no .env)
  • Full test_webhooks.py: 15 passed, 1 pre-existing failure (test_plane_webhook_generates_sequential_ids — off-limits, same root cause)
## Summary 3 tests in tests/test_webhooks.py were hitting live Plane API in CI (clean env, no .env → Connection refused). This PR adds missing @patch decorators to isolate them. ### Changes (tests/test_webhooks.py only) 1. **test_plane_webhook_creates_task**: Added mocks for `src.plane_sync.fetch_issue_fields`, `src.plane_sync.fetch_issue_sequence_id`, `src.plane_sync.add_comment`. Also corrected the trigger event from `work_item.created` to `issue.updated+InProgress` to match the current pipeline flow (work_item.created no longer starts the pipeline — Feature 1). 2. **test_gitea_push_with_adr_advances_stage**: Added `@patch("src.webhooks.gitea.plane_notify_stage")` to isolate the Plane stage notification call. Fixed `mock_launcher.launch.assert_called_once()` → `mock_plane_notify.assert_called_once()` (code now uses enqueue_job, not launcher.launch directly). 3. **test_gitea_ci_failure_on_development_notifies_qg_failure**: Already PASSED without changes. ### Verification - 3 targeted tests: PASSED in clean docker env (ro mount, no .env) - Full test_webhooks.py: 15 passed, 1 pre-existing failure (test_plane_webhook_generates_sequential_ids — off-limits, same root cause)
admin added 1 commit 2026-06-04 22:15:47 +03:00
test: isolate webhook tests from live Plane API (fix CI)
Some checks failed
CI / test (push) Failing after 9s
CI / test (pull_request) Failing after 9s
7bbab9c38b
admin force-pushed fix/isolate-webhook-tests-from-plane from 0d28a0835c to 7bbab9c38b 2026-06-04 22:15:47 +03:00 Compare
admin added 1 commit 2026-06-04 22:38:11 +03:00
test: migrate sequential_ids test to In Progress contract
Some checks failed
CI / test (push) Failing after 9s
CI / test (pull_request) Failing after 9s
e856e0940b
admin added 1 commit 2026-06-05 00:00:27 +03:00
test: reset webhook secret per-test to fix cross-file isolation (CI green)
All checks were successful
CI / test (push) Successful in 10s
CI / test (pull_request) Successful in 10s
1baae81165
Adds autouse fixture _reset_webhook_secrets to tests/conftest.py that
resets the process-wide Pydantic settings singleton before every test:

1. gitea_webhook_secret / plane_webhook_secret → "" (HMAC disabled by
   default). Tests that deliberately test the 401 path
   (test_webhook_dedup.py:268,278) override this with their own monkeypatch
   which runs after autouse fixtures and wins for that test only.

2. db_path → os.environ["ORCH_DB_PATH"] (last written value after all test
   modules are imported). Without this, test_webhook_dedup.py (imported
   first alphabetically) seeds settings.db_path = dedup.db, while
   test_webhooks.py setup_db tries to remove test_orchestrator.db — leaving
   the DB dirty between tests that share a branch name and causing
   get_task_by_repo_branch() to return a stale row with the wrong stage.
   Per-test monkeypatches in test_webhook_dedup.setup_db still override it.

Root cause: both leaks come from the same singleton settings being read once
at import, before any per-test isolation runs. The autouse fixture is the
correct per-test reset point for process-wide singletons.

Result: pytest tests/ → 294 passed, 0 failed (was 10 failed/284 passed).
admin merged commit d0a34249cc into main 2026-06-05 07:29:05 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/orchestrator#27