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:
medmunds
2016-02-04 12:14:01 -08:00
parent 9c938c8e85
commit f95d5d66dc
2 changed files with 9 additions and 3 deletions

View File

@@ -95,7 +95,7 @@ class DjrillWebhookViewTests(TestCase):
self.assertEqual(data, test_event)
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', {
'mandrill_events': json.dumps([test_event])
})
@@ -117,7 +117,7 @@ class DjrillWebhookViewTests(TestCase):
self.assertEqual(data, test_event)
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', {
'mandrill_events': json.dumps([test_event])
})