I was wondering what folks use for unit testing web.py apps. I'd like
something where I could just run a few SQL scripts to restore the
database to a consistent state, simulate an HTTP GET or POST, and then
run some assertions on the returned result. Something like:
empty_db = ['schema.sql']
sample_users = empty_db + ['users.sql']
web.test.load_db(sample_users);
web.test.post('/my_app/form', field1='me', field2='myvalue',
field3='afile')
web.test.assert_redirect(302, '/my_app/results')
web.test.assert_db_contains('user_roles', db_field1='me',
db_field2='myvalue')
web.test.assert_cookie('last_val', 'myvalue')
web.test.get('/my_app/results')
web.test.assert_contains('Thank you for submitting your form.')
web.test.assert_regexp('(<html>)?myvalue')
Is there anything like this already in existence, or any easy way to
adapt present Python testing frameworks (unittest etc.) to do this?
I'm not averse to hacking something up, but I want to make sure
there's nothing already in existence that does what I want.
Regards,
Jonathan
Hi all,
I was wondering what folks use for unit testing web.py apps. I'd like
something where I could just run a few SQL scripts to restore the
database to a consistent state, simulate an HTTP GET or POST, and then
run some assertions on the returned result. Something like: