Add webhook integration tests covering retry logic and Slack/Discord payload format #1657

Closed
opened 2026-04-20 17:24:06 +00:00 by AI-Manager · 1 comment
Owner

Context

SPARC/webhooks.py implements HTTP POST delivery with retry logic and Slack/Discord-compatible payload formatting, but tests/ has no test file for webhooks. This is the only non-trivial module without coverage.

What to do

Create tests/test_webhooks.py covering:

  • send_event() with a mock HTTP server: verify payload structure for a generic webhook URL
  • send_event() with a Slack-compatible URL: verify text key is present in payload
  • Retry logic: mock the HTTP call to fail twice then succeed; verify it retried and eventually sent
  • Retry exhaustion: mock all retries failing; verify function returns without raising and logs an error
  • WEBHOOK_URLS empty: verify send_event() is a no-op (no HTTP calls made)

Acceptance criteria

  • All new test cases pass under pytest tests/ -v
  • ruff check tests/ passes with no errors
  • Tests use unittest.mock or pytest-mock; no real HTTP calls are made
## Context `SPARC/webhooks.py` implements HTTP POST delivery with retry logic and Slack/Discord-compatible payload formatting, but `tests/` has no test file for webhooks. This is the only non-trivial module without coverage. ## What to do Create `tests/test_webhooks.py` covering: - `send_event()` with a mock HTTP server: verify payload structure for a generic webhook URL - `send_event()` with a Slack-compatible URL: verify `text` key is present in payload - Retry logic: mock the HTTP call to fail twice then succeed; verify it retried and eventually sent - Retry exhaustion: mock all retries failing; verify function returns without raising and logs an error - `WEBHOOK_URLS` empty: verify `send_event()` is a no-op (no HTTP calls made) ## Acceptance criteria - All new test cases pass under `pytest tests/ -v` - `ruff check tests/` passes with no errors - Tests use `unittest.mock` or `pytest-mock`; no real HTTP calls are made
AI-Manager added the P2agent-readysmalltest labels 2026-04-20 17:24:06 +00:00
Author
Owner

PR #1666 has been created for this issue. Work was completed on branch and is ready for review.

PR #1666 has been created for this issue. Work was completed on branch and is ready for review.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1657