Programatic form submission in shell / py.test

27 views
Skip to first unread message

Octavian G

unread,
Aug 1, 2015, 12:32:35 PM8/1/15
to web2py-users
Hello,

     I'm testing my application code using py.test (not viniciusban's system). I have a something.py controller, with an add function.

In forms_something (a module):

def add_form(o):
    if some conditions:
        o['add_form'] = add_form

In something.py:

from forms_something import add_form

and then I use it in add(), like:

o = {}
add_form(o)

Now, if I go to the shell, with "-S appname/something -M", I can generate the appname/something/add html using "response.render('something/add.html', add())". This is enough to see the form was generated based on the specified conditions. What I want to do next is submit the form and check that it works fine (validates, generates errors), and that various DB changes do occur.

At this moment, I tried request.env.update(request_method='POST'), but even if I do that, the response.render only shows the form in the initial stage. I also did something like request.post_vars.update(form_field='value'), but with no effect. My intuition tells me it's just a matter of POSTing instead of GETting, but I don't know what to do next.

Richard Vézina

unread,
Aug 4, 2015, 11:19:28 AM8/4/15
to web2py-users
You may also consider this approach : https://github.com/niphlod/welcome_augmented

Which is BDD centric and use Splinter (Python wrap of Selenium HQ) to perform test...

Sorry I don't have clue for your issue...

:)

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages