1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
import twilltestlib
import twill
from twill import namespaces, commands
from twill.errors import TwillAssertionError
import mechanize
def setup_module():
global url
url = twilltestlib.get_url()
def test_select_multiple():
namespaces.new_local_dict()
twill.commands.reset_browser()
browser = twill.get_browser()
try:
browser.get_title()
assert 0, "should never get here"
except mechanize.BrowserStateError:
pass
commands.go(url)
commands.go('/test_checkboxes')
commands.fv('1', 'checkboxtest', 'one')
commands.fv('1', 'checkboxtest', 'two')
commands.fv('1', 'checkboxtest', 'three')
commands.fv('1', 'checkboxtest', '-one')
commands.fv('1', 'checkboxtest', '-two')
commands.fv('1', 'checkboxtest', '-three')
commands.submit()
assert not 'CHECKBOXTEST' in browser.get_html()
commands.fv('1', 'checkboxtest', '+one')
commands.fv('1', 'checkboxtest', '+two')
commands.fv('1', 'checkboxtest', '+three')
commands.submit()
assert 'CHECKBOXTEST: ==one,two,three==' in browser.get_html()
commands.fv('1', 'checkboxtest', '-one')
commands.fv('1', 'checkboxtest', '-two')
commands.fv('1', 'checkboxtest', '-three')
commands.submit()
assert not 'CHECKBOXTEST' in browser.get_html()
def test_select_single():
namespaces.new_local_dict()
twill.commands.reset_browser()
browser = twill.get_browser()
try:
browser.get_title()
assert 0, "should never get here"
except mechanize.BrowserStateError:
pass
commands.go(url)
commands.go('/test_checkboxes')
for x in ('1', '0', 'True', 'False'):
try:
commands.fv('1', 'checkboxtest', x)
assert False, ("Should not be able to use a bool style for when "
"there are multiple checkboxes")
except:
pass
|