On Mon, 2008-12-08 at 20:16 -0800, Jason Sidabras wrote:
> Sorry, I guess I missed that part.
> 
> In my template it checks if there is a user logged in or not. If there
> is not a user, it defaults the hidden field to send_id=1 and has a
> form to place an email address. If the user is logged in the template
> uses the pk_id from the user (in the case of non-admin pk=2 and up)
> and then places the username a hidden field also.
> 
> So when the send button is pushed it sends both the sender_id="2" (or
> whichever user) and the username="test_userwith_pk2"
> 
> So when I am testing and I have an anonymous user a simple post will
> work to test my views, but when the user is logged in data comes from
> the template so just "post" won't do. I would need to simulate
> clicking the submit button.
> 
> Twill seems to do this similar to Perl's mechanize module. I am
> familiar with this 'find forum' submit type of coding but I was
> wondering if django has a way to grab these hidden fields and place
> them in the post data when i run a
> 
> c = Client()
> c.post('/contact-us/', {'some': 'variables' [+ hidden variables from
> template]})

No, Django's test.client.Client is simulating only the HTTP side of
things. It doesn't parse any HTML. Twill goes partway by parsing the
HTML, but then if you have modifications made by other purposes (e.g.
Javascript, it doesn't pick those up). Short of using a web browser (the
Selenium approach), there isn't an ideal way here.

Probably wouldn't be too hard to write a subclass that did twill-like
parsing (even using Twill) if you were sufficiently motivated.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to