On Tue, Sep 30, 2008 at 5:20 AM, Tim Sawyer <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> 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?
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 %-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---