mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Avoid weak ref to local signal receiver in webhook tests.
Webhook tests define a local signal receiver function, so connect it using the `weak=False` option to set a good example. (This isn't technically needed in the tests: the test receivers are only connected while their definitions are still in scope, so they couldn't possibly be garbage collected. But it doesn't hurt, and it's good practice in case the test code gets copied.) Also update the webhook docs to have a direct link to Django's "listening to signals" info.
This commit is contained in:
@@ -95,7 +95,7 @@ class DjrillWebhookViewTests(TestCase):
|
|||||||
self.assertEqual(data, test_event)
|
self.assertEqual(data, test_event)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
webhook_event.connect(my_callback)
|
webhook_event.connect(my_callback, weak=False) # local callback func, so don't use weak ref
|
||||||
response = self.client.post('/webhook/?secret=abc123', {
|
response = self.client.post('/webhook/?secret=abc123', {
|
||||||
'mandrill_events': json.dumps([test_event])
|
'mandrill_events': json.dumps([test_event])
|
||||||
})
|
})
|
||||||
@@ -117,7 +117,7 @@ class DjrillWebhookViewTests(TestCase):
|
|||||||
self.assertEqual(data, test_event)
|
self.assertEqual(data, test_event)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
webhook_event.connect(my_callback)
|
webhook_event.connect(my_callback, weak=False) # local callback func, so don't use weak ref
|
||||||
response = self.client.post('/webhook/?secret=abc123', {
|
response = self.client.post('/webhook/?secret=abc123', {
|
||||||
'mandrill_events': json.dumps([test_event])
|
'mandrill_events': json.dumps([test_event])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -114,7 +114,11 @@ Webhook Notifications
|
|||||||
|
|
||||||
Once you've enabled webhooks, Djrill will send a ``djrill.signals.webhook_event``
|
Once you've enabled webhooks, Djrill will send a ``djrill.signals.webhook_event``
|
||||||
custom `Django signal`_ for each Mandrill event it receives.
|
custom `Django signal`_ for each Mandrill event it receives.
|
||||||
You can connect to this signal for further processing.
|
You can connect your own receiver function to this signal for further processing.
|
||||||
|
|
||||||
|
Be sure to read Django's `listening to signals`_ docs for information on defining
|
||||||
|
and connecting signal receivers.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -161,6 +165,8 @@ The available fields in the `data` param are described in Mandrill's documentati
|
|||||||
.. _Django signal: https://docs.djangoproject.com/en/stable/topics/signals/
|
.. _Django signal: https://docs.djangoproject.com/en/stable/topics/signals/
|
||||||
.. _inbound webhooks:
|
.. _inbound webhooks:
|
||||||
http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-
|
http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-
|
||||||
|
.. _listening to signals:
|
||||||
|
https://docs.djangoproject.com/en/stable/topics/signals/#listening-to-signals
|
||||||
.. _sent-message webhooks: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
|
.. _sent-message webhooks: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
|
||||||
.. _whitelist/blacklist sync webooks:
|
.. _whitelist/blacklist sync webooks:
|
||||||
https://mandrill.zendesk.com/hc/en-us/articles/205583297-Sync-Event-Webhook-format
|
https://mandrill.zendesk.com/hc/en-us/articles/205583297-Sync-Event-Webhook-format
|
||||||
|
|||||||
Reference in New Issue
Block a user