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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
#### This is a script designed to test basic functionality for most of
#### the commands in twill. The only things not tested are the commands
#### that only print stuff out, and:
####
#### add_auth, extend_with, runfile, setglobal/setlocal interaction
#### also, be sure to test $/__ interpolation.
#debug http 1
#debug commands 1
setglobal init __url__
# should fail silently
back
go $init
code 200
# miscellaneous gunk for better code coverage
#save_html /dev/null # doesn't work on Windows... <sigh>
sleep 0
agent test
clear_cookies
go $init
code 200
showlinks
# intro page.
find "Your session ID is None"
find "this is visit #0"
find 'You are logged in as "None"'
notfind 'this is visit #1'
## reload and assign a session ID
reload
code 200
notfind "Your session ID is None"
# increment visit number.
follow increment
code 200
find "this is visit #1"
reload
code 200
find "this is visit #2"
# save & then clear cookies.
show_cookies
save_cookies 'test-basic.cookies'
clear_cookies
# return to main page; did clear work?
go ./
find "Your session ID is None"
find "this is visit #0"
find 'You are logged in as "None"'
notfind 'this is visit #2'
# yep! all right. load cookies, check that.
load_cookies 'test-basic.cookies'
back
back
back
back
go ./
code 200
notfind "Your session ID is None"
find "this is visit #2"
# ok, cookies check out. now check login/access restricted.
showhistory
go restricted/
code 403
back
showhistory
echo 'URL IS' __url__
url $init
show
find 'this is visit #2'
reload
echo 'URL4 is' __url__
#code 200
#find 'this is visit #2'
go ./login
# test formclear
showforms
fv 1 username test
formclear 1
fv 1 "submit me" click
submit
code 200
find "Log in:"
fv 1 username test
setlocal name "submit you"
setglobal name $name
fv 1 $name click
submit
code 200
show
find 'You are logged in as "test"'
find 'this is visit #2'
save_cookies 'test-basic.cookies'
clear_cookies
# ok, clear username?
go ./
code 200
find 'You are logged in as "None"'
# yep, reload & visit restricted.
load_cookies 'test-basic.cookies'
go ./
code 200
find 'You are logged in as "test"'
go restricted/
code 200
# success! log out, and try again.
go ../logout
go ./restricted
code 403
### test input/password
back
go ./login
show
code 200
getinput "Enter some (weird) input: "
fv 1 username __input__
fv 1 "submit me" click
submit
code 200
find __input__
echo 'found"' __input__ '"on the page, hooray!'
getpassword "Enter your (weird) secret identity: "
go ./login
fv 1 "submit me" click
fv 1 username __password__
submit
show
code 200
find __password__
echo 'found"' __password__ '"on the page, hooray!'
### test space transform.
go ./
code 200
# test links with spaces in the URL
follow "test spaces"
code 200
# test links with spaces in the link text
back
follow "test spaces2"
code 200
# test quoted handling
echo __input__
echo '__noinput__'
# comments at end of line!
go ./ ##### this is a test
# submit-button-less form
go ./simpleform
fv 1 n testa
fv 1 n2 testb
submit
find "testa testb"
# file upload
go ./upload_file
formfile 1 upload ../README.txt
submit
code 200
find "twill: a simple scripting"
# ok, separate issue: redirect + enctype problem that I fixed in
# wwwsearch, urllib2_support, HTTPRedirectHandler, redirect_request.
# (redirects after a POST retain content-type inappropriately)
## @@CTB
go ./formpostredirect
fv 1 test "hello"
submit
show
code 200
go /
runfile test-go.twill
|