Add tests for the "save draft" feature
This commit is contained in:
parent
262684b678
commit
392eaca853
|
@ -0,0 +1,84 @@
|
|||
import twill
|
||||
import datetime
|
||||
|
||||
import utils
|
||||
|
||||
def setup():
|
||||
'''Set up test form allowing draft'''
|
||||
utils.login('admin')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/admin/forms/new
|
||||
fv 1 name draft
|
||||
submit
|
||||
|
||||
fv 1 label name
|
||||
submit
|
||||
|
||||
fv 1 label name2
|
||||
submit
|
||||
|
||||
go http://localhost:10003/admin/forms/1/edit
|
||||
fv 1 allow_drafts True
|
||||
submit
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def teardown():
|
||||
'''Tear down form'''
|
||||
utils.login('admin')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/admin/forms/1/delete
|
||||
submit
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def test_draft_require_session():
|
||||
'''Draft: session required'''
|
||||
twill.commands.reset_browser()
|
||||
twill.commands.go('http://localhost:10003/draft')
|
||||
assert(not 'savedraft' in twill.commands.browser.get_html())
|
||||
|
||||
def test_draft_save():
|
||||
'''Draft: save'''
|
||||
utils.login('test')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/draft
|
||||
fv 1 f1 Plip
|
||||
fv 1 f2 Plop
|
||||
submit savedraft
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def test_draft_restore():
|
||||
'''Draft: restore'''
|
||||
utils.login('test')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/
|
||||
find 'Your Current Drafts'
|
||||
go http://localhost:10003/draft/1
|
||||
find Plip
|
||||
find Plop
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def test_draft_save_incomplete():
|
||||
'''Draft: save'''
|
||||
utils.login('test')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/draft
|
||||
fv 1 f1 Plip
|
||||
submit savedraft
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def test_draft_restore_incomplete():
|
||||
'''Draft: restore'''
|
||||
utils.login('test')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/
|
||||
find 'Your Current Drafts'
|
||||
go http://localhost:10003/draft/1
|
||||
find Plip
|
||||
''')
|
||||
utils.logout()
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
import twill
|
||||
import datetime
|
||||
import utils
|
||||
|
||||
def setup():
|
||||
'''Set up test form with date widget'''
|
||||
utils.login('admin')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/admin/forms/new
|
||||
fv 1 name date
|
||||
|
@ -19,6 +21,7 @@ def teardown():
|
|||
go http://localhost:10003/admin/forms/1/delete
|
||||
submit
|
||||
''')
|
||||
utils.logout()
|
||||
|
||||
def test_fill_base_form():
|
||||
'''Date widget: basis'''
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import twill
|
||||
import os
|
||||
|
||||
import utils
|
||||
|
||||
def setup():
|
||||
'''Set up test form'''
|
||||
utils.login('admin')
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/admin/forms/new
|
||||
fv 1 name file-name
|
||||
|
@ -23,7 +26,7 @@ def teardown():
|
|||
go http://localhost:10003/admin/forms/1/delete
|
||||
submit
|
||||
''')
|
||||
|
||||
utils.logout()
|
||||
|
||||
def test_fill_form():
|
||||
'''File widget: fill a form, then go back and ask for the same file, with an error
|
||||
|
@ -40,7 +43,6 @@ submit previous
|
|||
fv 1 f1$orexisting True
|
||||
fv 1 f2 ''
|
||||
submit
|
||||
save_html /tmp/t.html
|
||||
find 'errors processing your form'
|
||||
''')
|
||||
os.unlink('/tmp/.tests/upload.txt')
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import twill
|
||||
|
||||
users = {
|
||||
'test': 'test',
|
||||
'admin': 'admin'
|
||||
}
|
||||
|
||||
def login(username='test'):
|
||||
twill.commands.reset_browser()
|
||||
password = users.get(username)
|
||||
twill.execute_string('''
|
||||
go http://localhost:10003/login
|
||||
fv 1 username %s
|
||||
fv 1 password %s
|
||||
submit''' % (username, password))
|
||||
|
||||
def logout():
|
||||
twill.commands.reset_browser()
|
||||
|
Loading…
Reference in New Issue