def test_no_hook(self): addr, httpd, httpd_thread = self.start_server() call_hook(TEST_EVENT, None) self.shutdown_server(httpd, httpd_thread) self.assertEqual(httpd.recorded, [])
def get(self, request, **kwargs): self.object = self.get_object() if not self.object.can_edit(): raise PermissionDenied() self.object.published = True self.object.save() if self.object.personal: call_hook(POST_PUBLISHED_PERSONAL, self.object) else: call_hook(POST_PUBLISHED, self.object) return HttpResponseRedirect(self.object.get_absolute_url())
def test_template(self): addr, httpd, httpd_thread = self.start_server() hook = Hook(event=TEST_EVENT, url='http://{}:{}/addr'.format(addr[0], addr[1]), method='POST', body='content {{ object.data }}', group=self.group) hook.save() call_hook(TEST_EVENT, {'data': '123'}) self.shutdown_server(httpd, httpd_thread) self.assertEqual(httpd.recorded, [('POST', '/addr', b'content 123')])
def test_simple(self): addr, httpd, httpd_thread = self.start_server() hook = Hook(event=TEST_EVENT, url='http://{}:{}/addr'.format(addr[0], addr[1]), method='POST', body='content', group=self.group) hook.save() call_hook(TEST_EVENT, None) self.shutdown_server(httpd, httpd_thread) self.assertEqual(httpd.recorded, [('POST', '/addr', b'content')])
def event_suggestion_signal(sender, instance, created, **kwargs): if created: call_hook(EVENT_SUGGESTED, instance) else: call_hook(EVENT_SUGGESTED_CHANGED, instance)