[Django]-Django Unittest how to adjust client.post to set data in request.META

3👍

extra is not a separate argument to the post method, but rather an catch-all keyword arguments variable. To pass your headers, simply use:

        response = self.client.post('/webhook/', data={'input': 'hi'}, 
                                content_type='application/json', follow=False,
                                secure=False, **header)

Also, make sure to include a HTTP_ prefix in your headers list.

Leave a comment