def test_comment_hook_serializer_method(self):
        def serialize_hook(comment, hook):
            return { 'hook': hook.dict(),
                     'data': { 'id': comment.id,
                               'comment': comment.comment,
                               'user': { 'username': comment.user.username,
                                         'email': comment.user.email}}}
        Comment.serialize_hook = serialize_hook
        hook, comment, payload = self.perform_create_request_cycle()

        self.assertEquals(hook.id, payload['hook']['id'])
        self.assertEquals('comment.added', payload['hook']['event'])
        self.assertEquals(hook.target, payload['hook']['target'])

        self.assertEquals(comment.id, payload['data']['id'])
        self.assertEquals('Hello world!', payload['data']['comment'])
        self.assertEquals('bob', payload['data']['user']['username'])

        del Comment.serialize_hook
Use custom serialize_hook on the Comment model.
dataset/ETHPy150Open zapier/django-rest-hooks/rest_hooks/tests.py/RESTHooksTest.test_comment_hook_serializer_method