I'm having a problem testing with:
c = Client()
response = c.post('/guestbook/', {
'name' : 'name',
'email' : 'email',
'realurl' : 'url',
})
in that my view checks the referer header available from
request.META['HTTP_REFERER'] to make sure the form was submitted from the
correct url.
Can I simulate this header with the test client?
Thanks,
Tim.
Yes.
The full method signature for client.post() is:
def post(self, path, data={}, content_type=MULTIPART_CONTENT, **extra):
'extra' is an argument that allows you to specify any additional
header data that you want to send with the request. So, if you want to
set the HTTP REFERRER in your request, make a call like:
>>> response = c.post('/guestbook/', {...your data...}, HTTP_REFERRER='foo')
Yours
Russ Magee %-)
Excellent, thanks!
Tim.