Exemple #1
0
    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, [])
Exemple #2
0
    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, [])
Exemple #3
0
 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())
Exemple #4
0
    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')])
Exemple #5
0
    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')])
Exemple #6
0
 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())
Exemple #7
0
    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')])
Exemple #8
0
    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')])
Exemple #9
0
def event_suggestion_signal(sender, instance, created, **kwargs):
    if created:
        call_hook(EVENT_SUGGESTED, instance)
    else:
        call_hook(EVENT_SUGGESTED_CHANGED, instance)