Skip to content

DM-54689: Handler-level webhook tests — signed truncated push with compare-API fallback; empty-commits no-enqueue #271

@jonathansick

Description

@jonathansick

Metadata

Field Value
Parent PRD #232
Jira Key DM-54689
Jira URL https://rubinobs.atlassian.net/browse/DM-54689
Task Order 26
Type AFK
Blocked by #269
Parallel with #270
Branch tickets/DM-54689-github-webhook

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:

  1. 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).
  2. 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

Metadata

Assignees

No one assigned

    Labels

    prd-taskImplementation task from a PRD

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions