Metadata
Origin
Review of PR #264
What to build
PR #264's service-layer tests cover the compare-API fallback thoroughly, and extract_changed_paths_from_push is unit-tested for empty-commits → []. But the end-to-end HTTP path for those two scenarios is not exercised. Add two handler-level tests in tests/handlers/webhooks_github_test.py:
- Truncated-push compare-API fallback. A signed POST with a truncated push payload (
size > len(commits), or len(commits) >= _MAX_PUSH_COMMITS) → 200 + exactly one dashboard_sync enqueue, with the GitHub compare API mocked via mock_github.seed_compare(...) (existing helper at tests/support/github_mock.py:229-269).
- Empty-commits no-enqueue. A signed POST with
commits=[] and size=0 → 200 + zero dashboard_sync enqueues, with the compare API not called (assert via respx that the compare route saw zero requests).
Approach sketch
Mirror the existing test_post_signed_push_enqueues_dashboard_sync:
- For the truncated case: build a payload with
size larger than commits (or with len(commits) >= _MAX_PUSH_COMMITS), seed the compare endpoint with a single matching path, and assert one enqueue.
- For the empty case: build a payload with
commits=[] and size=0, register no compare-API mock, and assert the compare route saw zero requests.
Use the new helpers from #269:
set_github_secrets(...) on ContextDependency (in place of the private-attr fixture).
count_jobs_by_name(arq_queue, "dashboard_sync") (in place of _arq_queue._job_metadata).
Acceptance criteria
Metadata
tickets/DM-54689-github-webhookOrigin
Review of PR #264
What to build
PR #264's service-layer tests cover the compare-API fallback thoroughly, and
extract_changed_paths_from_pushis unit-tested for empty-commits →[]. But the end-to-end HTTP path for those two scenarios is not exercised. Add two handler-level tests intests/handlers/webhooks_github_test.py:size > len(commits), orlen(commits) >= _MAX_PUSH_COMMITS) → 200 + exactly onedashboard_syncenqueue, with the GitHub compare API mocked viamock_github.seed_compare(...)(existing helper attests/support/github_mock.py:229-269).commits=[]andsize=0→ 200 + zerodashboard_syncenqueues, with the compare API not called (assert via respx that the compare route saw zero requests).Approach sketch
Mirror the existing
test_post_signed_push_enqueues_dashboard_sync:sizelarger thancommits(or withlen(commits) >= _MAX_PUSH_COMMITS), seed the compare endpoint with a single matching path, and assert one enqueue.commits=[]andsize=0, register no compare-API mock, and assert the compare route saw zero requests.Use the new helpers from #269:
set_github_secrets(...)onContextDependency(in place of the private-attr fixture).count_jobs_by_name(arq_queue, "dashboard_sync")(in place of_arq_queue._job_metadata).Acceptance criteria
dashboard_syncenqueue when the signed push has truncated commits and the compare API is mocked.dashboard_syncenqueues when the signed push carriescommits=[]andsize=0, with the compare API not called.TC_HOST=localhost TESTCONTAINERS_RYUK_DISABLED=true uv run --only-group=nox nox -s test -- tests/handlers/webhooks_github_test.py.