MockSlackWebhook#

class safir.testing.slack.MockSlackWebhook(url)#

Bases: object

Represents a Slack incoming webhook and remembers what was posted.

Parameters:

url (str) – URL that the mock has been configured to listen on.

messages#

Messages that have been posted to the webhook so far.

Type:

list[dict[str, Any]]

url#

URL that the mock has been configured to listen on.

Methods Summary

post_webhook(request)

Post a Slack message.

Methods Documentation

post_webhook(request)#

Post a Slack message.

The provided message is stored in the messages attribute.

Parameters:

request (Request) – Incoming request.

Returns:

Always returns a 201 response.

Return type:

Response

Notes

For now, this returns an httpx.Response instead of using HTTPX2 since respx still expects that return value from side effect mocks.